Commits

Mike Bayer committed bf37bc5

- removed get_session()
- removed mapperextension get_by(), select(), select_by()
- fixed sqlsoup's need for 'c'

Comments (0)

Files changed (7)

lib/sqlalchemy/ext/sqlsoup.py

         klass = TableClassType(mapname, (object,), {})
     else:
         klass = SelectableClassType(mapname, (object,), {})
-
+    
     def __cmp__(self, o):
         L = self.__class__.c.keys()
         L.sort()
     for m in ['__cmp__', '__repr__']:
         setattr(klass, m, eval(m))
     klass._table = selectable
+    klass.c = expression.ColumnCollection()
     mappr = mapper(klass,
                    selectable,
                    extension=objectstore.extension,
                    allow_null_pks=_is_outer_join(selectable),
                    **mapper_kwargs)
-    klass._query = Query(mappr)
+                   
+    for k in mappr.iterate_properties:
+        klass.c[k.key] = k.columns[0]
+
+    klass._query = objectstore.query_property()
     return klass
 
 class SqlSoup:

lib/sqlalchemy/orm/interfaces.py

     def init_failed(self, mapper, class_, oldinit, instance, args, kwargs):
         return EXT_CONTINUE
 
-    def get_session(self):
-        """Retrieve a contextual Session instance with which to
-        register a new object.
-
-        Note: this is not called if a session is provided with the
-        `__init__` params (i.e. `_sa_session`).
-        """
-
-        return EXT_CONTINUE
-
     def load(self, query, *args, **kwargs):
         """Override the `load` method of the Query object.
 
 
         return EXT_CONTINUE
 
-    def get_by(self, query, *args, **kwargs):
-        """Override the `get_by` method of the Query object.
-
-        The return value of this method is used as the result of
-        ``query.get_by()`` if the value is anything other than
-        EXT_CONTINUE.
-
-        DEPRECATED.
-        """
-
-        return EXT_CONTINUE
-
-    def select_by(self, query, *args, **kwargs):
-        """Override the `select_by` method of the Query object.
-
-        The return value of this method is used as the result of
-        ``query.select_by()`` if the value is anything other than
-        EXT_CONTINUE.
-
-        DEPRECATED.
-        """
-
-        return EXT_CONTINUE
-
-    def select(self, query, *args, **kwargs):
-        """Override the `select` method of the Query object.
-
-        The return value of this method is used as the result of
-        ``query.select()`` if the value is anything other than
-        EXT_CONTINUE.
-
-        DEPRECATED.
-        """
-
-        return EXT_CONTINUE
-
-
     def translate_row(self, mapper, context, row):
         """Perform pre-processing on the given result row and return a
         new row instance.

lib/sqlalchemy/orm/mapper.py

         """Return the primary mapper corresponding to this mapper's class key (class + entity_name)."""
         return self.class_manager.mappers[self.entity_name]
 
-    def get_session(self):
-        """Return the contextual session provided by the mapper
-        extension chain, if any.
-
-        Raise ``InvalidRequestError`` if a session cannot be retrieved
-        from the extension chain.
-        """
-
-        if 'get_session' in self.extension.methods:
-            s = self.extension.get_session()
-            if s is not EXT_CONTINUE:
-                return s
-
-        raise sa_exc.InvalidRequestError("No contextual Session is established.")
-
     def identity_key_from_row(self, row, adapter=None):
         """Return an identity-map key for use in storing/retrieving an
         item from the identity map.

lib/sqlalchemy/orm/scoping.py

     def configure(self, **kwargs):
         return _ScopedExt(self.context, **kwargs)
     
-    def get_session(self):
-        return self.context.registry()
-
     def instrument_class(self, mapper, class_):
         class query(object):
             def __getattr__(s, key):

lib/sqlalchemy/orm/strategies.py

 
         session = sessionlib._state_session(state)
         if session is None:
-            try:
-                session = instance_mapper.get_session()
-            except sa_exc.InvalidRequestError:
-                raise sa_exc.UnboundExecutionError("Parent instance %s is not bound to a Session, and no contextual session is established; lazy load operation of attribute '%s' cannot proceed" % (mapperutil.state_str, self.key))
+            raise sa_exc.UnboundExecutionError("Parent instance %s is not bound to a Session; lazy load operation of attribute '%s' cannot proceed" % (mapperutil.state_str, self.key))
 
         q = session.query(prop.mapper).autoflush(False)._adapt_all_clauses()
         

test/orm/lazy_relations.py

         q = sess.query(User)
         assert [User(id=7, addresses=[Address(id=1, email_address='jack@bean.com')])] == q.filter(users.c.id == 7).all()
 
-    def test_bindstosession(self):
-        """test that lazy loaders use the mapper's contextual session if the parent instance
-        is not in a session, and that an error is raised if no contextual session"""
-
-        ctx = scoped_session(create_session)
-        m = mapper(User, users, properties = dict(
-            addresses = relation(mapper(Address, addresses, extension=ctx.extension), lazy=True)
-        ), extension=ctx.extension)
-        q = ctx.query(m)
-        u = q.filter(users.c.id == 7).first()
-        ctx.expunge(u)
-        assert User(id=7, addresses=[Address(id=1, email_address='jack@bean.com')]) == u
-
-        clear_mappers()
+    def test_needs_parent(self):
+        """test the error raised when parent object is not bound."""
 
         mapper(User, users, properties={
             'addresses':relation(mapper(Address, addresses), lazy=True)

test/orm/utils.py

     def test_basic(self):
         carrier = util.ExtensionCarrier()
 
-        assert 'get_session' not in carrier.methods
-        assert carrier.get_session() is interfaces.EXT_CONTINUE
-        assert 'get_session' not in carrier.methods
+        assert 'translate_row' not in carrier.methods
+        assert carrier.translate_row() is interfaces.EXT_CONTINUE
+        assert 'translate_row' not in carrier.methods
 
         self.assertRaises(AttributeError, lambda: carrier.snickysnack)
 
         class Partial(object):
             def __init__(self, marker):
                 self.marker = marker
-            def get_session(self):
+            def translate_row(self, row):
                 return self.marker
 
         carrier.append(Partial('end'))
-        assert 'get_session' in carrier.methods
-        assert carrier.get_session() == 'end'
+        assert 'translate_row' in carrier.methods
+        assert carrier.translate_row(None) == 'end'
 
         carrier.push(Partial('front'))
-        assert carrier.get_session() == 'front'
+        assert carrier.translate_row(None) == 'front'
 
         assert 'populate_instance' not in carrier.methods
         carrier.append(interfaces.MapperExtension)