diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-07-03 15:31:29 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-07-03 15:31:29 +0000 |
commit | c2108dafbde1b99b660350b5b17018c63c785ee1 (patch) | |
tree | e265c10eca951478a9717e186eb1d584bf354caa /lib/sqlalchemy/orm/scoping.py | |
parent | 41bc4d877f09eac7b408155cf17a8a216a7ace97 (diff) | |
download | sqlalchemy-c2108dafbde1b99b660350b5b17018c63c785ee1.tar.gz |
Session.mapper is now *deprecated*.
Call session.add() if you'd like a free-standing object to be
part of your session. Otherwise, a DIY version of
Session.mapper is now documented at
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper
The method will remain deprecated throughout 0.6.
M test/ext/test_declarative.py
M test/orm/test_scoping.py
M lib/sqlalchemy/orm/scoping.py
M CHANGES
Diffstat (limited to 'lib/sqlalchemy/orm/scoping.py')
-rw-r--r-- | lib/sqlalchemy/orm/scoping.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/sqlalchemy/orm/scoping.py b/lib/sqlalchemy/orm/scoping.py index 5559784c7..4339b68eb 100644 --- a/lib/sqlalchemy/orm/scoping.py +++ b/lib/sqlalchemy/orm/scoping.py @@ -5,7 +5,7 @@ # the MIT License: http://www.opensource.org/licenses/mit-license.php import sqlalchemy.exceptions as sa_exc -from sqlalchemy.util import ScopedRegistry, to_list, get_cls_kwargs +from sqlalchemy.util import ScopedRegistry, to_list, get_cls_kwargs, deprecated from sqlalchemy.orm import ( EXT_CONTINUE, MapperExtension, class_mapper, object_session ) @@ -23,12 +23,7 @@ class ScopedSession(object): Session = scoped_session(sessionmaker(autoflush=True)) - To map classes so that new instances are saved in the current - Session automatically, as well as to provide session-aware - class attributes such as "query": - - mapper = Session.mapper - mapper(Class, table, ...) + ... use session normally. """ @@ -57,8 +52,15 @@ class ScopedSession(object): self.registry().close() self.registry.clear() + @deprecated("Session.mapper is deprecated. " + "Please see http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper " + "for information on how to replicate its behavior.") def mapper(self, *args, **kwargs): - """return a mapper() function which associates this ScopedSession with the Mapper.""" + """return a mapper() function which associates this ScopedSession with the Mapper. + + DEPRECATED. + + """ from sqlalchemy.orm import mapper |