From: Fredrik Tolf Date: Sun, 8 Jul 2012 06:26:00 +0000 (+0200) Subject: Handle cookie attributes more flexibly. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=d99a17a601c0680a325338189e6eeac0eb7d7bce;p=wrw.git Handle cookie attributes more flexibly. --- diff --git a/wrw/cookie.py b/wrw/cookie.py index 37e8708..16ddf81 100644 --- a/wrw/cookie.py +++ b/wrw/cookie.py @@ -27,9 +27,10 @@ class cookiedict(object): return default return self.bk[name].value - def add(self, name, value, path = None): + def add(self, name, value, **kw): self.codec[name] = value - if path is not None: self.codec[name]["path"] = path + for key, value in kw.iteritems(): + self.codec[name][key] = value def __setitem__(self, name, value): self.add(name, value) @@ -40,5 +41,5 @@ def cookies(req): def get(req, name, default = None): return cookies(req).get(name, default) -def add(req, name, value, path = None): - cookies(req).add(name, value, path) +def add(req, name, value, **kw): + cookies(req).add(name, value, **kw) diff --git a/wrw/session.py b/wrw/session.py index edf8f7d..19bdb6b 100644 --- a/wrw/session.py +++ b/wrw/session.py @@ -179,7 +179,7 @@ class db(object): def ckfreeze(req): if sess.dirty(): if new: - cookie.add(req, self.cookiename, sess.id, self.path) + cookie.add(req, self.cookiename, sess.id, path=self.path) with self.lock: self.live[sess.id] = [sess.lock, sess] try: