Merge branch 'master' into python2
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 21 Dec 2011 07:16:56 +0000 (08:16 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 21 Dec 2011 07:16:56 +0000 (08:16 +0100)
Conflicts:
wrw/__init__.py

1  2 
wrw/__init__.py
wrw/dispatch.py
wrw/session.py
wrw/util.py

diff --cc wrw/__init__.py
@@@ -1,6 -1,6 +1,6 @@@
  __all__ = ["wsgiwrap", "restart", "cookie", "formdata"]
  
- from .util import wsgiwrap, persession
 -from util import wsgiwrap, persession, sessiondata
 -from dispatch import restart
 -import cookie
 -from form import formdata
++from .util import wsgiwrap, persession, sessiondata
 +from .dispatch import restart
 +from . import cookie
 +from .form import formdata
diff --cc wrw/dispatch.py
@@@ -18,9 -44,9 +44,9 @@@ def handle(req, startreq, handler)
          resp = [""]
          while True:
              try:
-                 resp = handler(req)
+                 resp = iterproxy(handler(req))
                  break
 -            except restart, i:
 +            except restart as i:
                  handler = i.handle
          req.commit(startreq)
          return resp
diff --cc wrw/session.py
Simple merge
diff --cc wrw/util.py
@@@ -19,3 -19,35 +19,35 @@@ def persession(data = None)
              return sess[callable].handle(req)
          return wrapper
      return dec
 -        super(sessiondata, self).__setattr__(name, value)
+ class sessiondata(object):
+     @classmethod
+     def get(cls, req):
+         sess = cls.sessdb().get(req)
+         with sess.lock:
+             try:
+                 return sess[cls]
+             except KeyError:
+                 ret = cls(req)
+                 ret._is_dirty = [False]
+                 sess[cls] = ret
+                 return ret
+     @classmethod
+     def sessdb(cls):
+         return session.default
+     def sessfrozen(self):
+         self._is_dirty[:] = [False]
+     def sessdirty(self):
+         return self._is_dirty[0]
+     def __setattr__(self, name, value):
+         if hasattr(self, "_is_dirty"):
+             self._is_dirty[:] = [True]
 -        super(sessiondata, self).__delattr__(name)
++        super().__setattr__(name, value)
+     def __delattr__(self, name):
++        super().__delattr__(name)
+         self._is_dirty[:] = [True]