Mike Bayer committed 44f4401

some adjustments to activemapper's objectstore to be composed against SessionContext
DynamicMetaData checks first for _engine before returning

  • Participants
  • Parent commits 1cc5a59

Comments (0)

Files changed (3)

 - upgraded all unittests to insert './lib/' into sys.path, 
 working around new setuptools PYTHONPATH-killing behavior
 - further fixes with attributes/dependencies/etc....
+- improved error handling for when DynamicMetaData is not connected
 - try/except when the mapper sets init.__name__ on a mapped class,

File lib/sqlalchemy/ext/

 # thread local SessionContext
-class Objectstore(SessionContext):
-    def __getattr__(self, key):
-        return getattr(self.current, key)
-    def get_session(self):
-        return self.current
+class Objectstore(object):
+    def __init__(self, *args, **kwargs):
+        self._context = SessionContext(*args, **kwargs)
+    def __getattr__(self, name):
+        return getattr(self._context.current, name)
 objectstore = Objectstore(create_session)
             # check for inheritence
             if hasattr(bases[0], "mapping"):
                 cls._base_mapper= bases[0].mapper
-                assign_mapper(objectstore, cls, cls.table, 
+                assign_mapper(objectstore._context, cls, cls.table, 
-                assign_mapper(objectstore, cls, cls.table)
+                assign_mapper(objectstore._context, cls, cls.table)
             cls.relations = relations
             ActiveMapperMeta.classes[clsname] = cls

File lib/sqlalchemy/

                 self.__engines[engine_or_url] = engine_or_url
             self.context._engine = engine_or_url
     def is_bound(self):
-        return self.context._engine is not None
+        return hasattr(self.context, '_engine') and self.context._engine is not None
     def dispose(self):
         """disposes all Engines to which this DynamicMetaData has been connected."""
         for e in self.__engines.values():
-    engine=property(lambda s:s.context._engine)
+    engine=property(lambda s:hasattr(s.context, '_engine') and s.context._engine or None)
 class SchemaVisitor(sql.ClauseVisitor):
     """defines the visiting for SchemaItem objects"""