From 67baacf01bae228cec392261a4791e9d08b0359e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 21 Feb 2007 21:55:45 +0000 Subject: [PATCH] - removed deprecated method of specifying custom collections on classes; you must now use the "collection_class" option. the old way was beginning to produce conflicts when people used assign_mapper(), which now patches an "options" method, in conjunction with a relationship named "options". (relationships take precedence over monkeypatched assign_mapper methods). --- CHANGES | 6 ++++++ lib/sqlalchemy/orm/attributes.py | 2 -- test/orm/unitofwork.py | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index b2bec558cb..df9d376125 100644 --- a/CHANGES +++ b/CHANGES @@ -61,6 +61,12 @@ ORM behavior with relationships from/to/between mappers, particularly polymorphic mappers, also their usage with Query, SelectResults. tickets include [ticket:439], [ticket:441], [ticket:448]. + - removed deprecated method of specifying custom collections on classes; + you must now use the "collection_class" option. the old way was + beginning to produce conflicts when people used assign_mapper(), which + now patches an "options" method, in conjunction with a relationship + named "options". (relationships take precedence over monkeypatched + assign_mapper methods). - extension() query option propigates to Mapper._instance() method so that all loading-related methods get called [ticket:454] - eager relation to an inheriting mapper wont fail if no rows returned for diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 398cdde6c5..6b2a1ee1a5 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -766,8 +766,6 @@ class AttributeManager(object): class_._state = property(_get_state) typecallable = kwargs.pop('typecallable', None) - if typecallable is None: - typecallable = getattr(class_, key, None) if isinstance(typecallable, InstrumentedAttribute): typecallable = None setattr(class_, key, self.create_prop(class_, key, uselist, callable_, typecallable=typecallable, **kwargs)) diff --git a/test/orm/unitofwork.py b/test/orm/unitofwork.py index f69519c139..28b0e9da02 100644 --- a/test/orm/unitofwork.py +++ b/test/orm/unitofwork.py @@ -55,7 +55,7 @@ class HistoryTest(UnitOfWorkTest): u = s.query(m).select()[0] print u.addresses[0].user -class CustomAttrTest(UnitOfWorkTest): +class CustomCollectionsTest(UnitOfWorkTest): def setUpAll(self): UnitOfWorkTest.setUpAll(self) global sometable, metadata, someothertable @@ -71,11 +71,11 @@ class CustomAttrTest(UnitOfWorkTest): class MyList(list): pass class Foo(object): - bars = MyList + pass class Bar(object): pass mapper(Foo, sometable, properties={ - 'bars':relation(Bar) + 'bars':relation(Bar, collection_class=MyList) }) mapper(Bar, someothertable) f = Foo() -- 2.47.2