global_extensions.append(SessionContextExt())
default_scope=scope
+
+ class ScopedProps(type):
+ pass
+ def makeprop(name):
+ def set(self, attr):
+ setattr(registry(), name, attr)
+ def get(self):
+ return getattr(registry(), name)
+ return property(get, set)
+ for prop in ('bind', 'dirty', 'identity_map'):
+ setattr(ScopedProps, prop, makeprop(prop))
+
class ScopedSess(Sess):
+ __metaclass__ = ScopedProps
def __new__(cls, **kwargs):
if len(kwargs):
scope = kwargs.pop('scope', default_scope)
Session.commit()
Session.delete(u)
Session.commit()
- self.assert_(a.address_id is not None and a.user_id is None and not Session().identity_map.has_key(u._instance_key) and Session().identity_map.has_key(a._instance_key))
+ self.assert_(a.address_id is not None and a.user_id is None and not Session.identity_map.has_key(u._instance_key) and Session.identity_map.has_key(a._instance_key))
def testonetoone(self):
m = mapper(User, users, properties = dict(
# change first users name and save
Session.update(u)
u.user_name = 'modifiedname'
- assert u in Session().dirty
+ assert u in Session.dirty
Session.commit()
# select both