[Sqlalchemy-commits] [6082] sqlalchemy/trunk: Session.mapper is now *deprecated*.
Brought to you by:
zzzeek
From: <co...@sq...> - 2009-07-03 15:31:33
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:':';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[6082] sqlalchemy/trunk: Session.mapper is now *deprecated*.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>6082</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2009-07-03 11:31:29 -0400 (Fri, 03 Jul 2009)</dd> </dl> <h3>Log Message</h3> <pre>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</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunkCHANGES">sqlalchemy/trunk/CHANGES</a></li> <li><a href="#sqlalchemytrunklibsqlalchemyormscopingpy">sqlalchemy/trunk/lib/sqlalchemy/orm/scoping.py</a></li> <li><a href="#sqlalchemytrunktestexttest_declarativepy">sqlalchemy/trunk/test/ext/test_declarative.py</a></li> <li><a href="#sqlalchemytrunktestormtest_scopingpy">sqlalchemy/trunk/test/orm/test_scoping.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunkCHANGES"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/CHANGES (6081 => 6082)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/CHANGES 2009-06-28 23:13:12 UTC (rev 6081) +++ sqlalchemy/trunk/CHANGES 2009-07-03 15:31:29 UTC (rev 6082) </span><span class="lines">@@ -12,6 +12,13 @@ </span><span class="cx"> the tests. [ticket:970] </span><span class="cx"> </span><span class="cx"> - orm </span><ins>+ - 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. + </ins><span class="cx"> - Fixed bug introduced in 0.5.4 whereby Composite types </span><span class="cx"> fail when default-holding columns are flushed. </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemyormscopingpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/orm/scoping.py (6081 => 6082)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/orm/scoping.py 2009-06-28 23:13:12 UTC (rev 6081) +++ sqlalchemy/trunk/lib/sqlalchemy/orm/scoping.py 2009-07-03 15:31:29 UTC (rev 6082) </span><span class="lines">@@ -5,7 +5,7 @@ </span><span class="cx"> # the MIT License: http://www.opensource.org/licenses/mit-license.php </span><span class="cx"> </span><span class="cx"> import sqlalchemy.exceptions as sa_exc </span><del>-from sqlalchemy.util import ScopedRegistry, to_list, get_cls_kwargs </del><ins>+from sqlalchemy.util import ScopedRegistry, to_list, get_cls_kwargs, deprecated </ins><span class="cx"> from sqlalchemy.orm import ( </span><span class="cx"> EXT_CONTINUE, MapperExtension, class_mapper, object_session </span><span class="cx"> ) </span><span class="lines">@@ -23,13 +23,8 @@ </span><span class="cx"> </span><span class="cx"> Session = scoped_session(sessionmaker(autoflush=True)) </span><span class="cx"> </span><del>- 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": </del><ins>+ ... use session normally. </ins><span class="cx"> </span><del>- mapper = Session.mapper - mapper(Class, table, ...) - </del><span class="cx"> """ </span><span class="cx"> </span><span class="cx"> def __init__(self, session_factory, scopefunc=None): </span><span class="lines">@@ -57,8 +52,15 @@ </span><span class="cx"> self.registry().close() </span><span class="cx"> self.registry.clear() </span><span class="cx"> </span><ins>+ @deprecated("Session.mapper is deprecated. " + "Please see http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper " + "for information on how to replicate its behavior.") </ins><span class="cx"> def mapper(self, *args, **kwargs): </span><del>- """return a mapper() function which associates this ScopedSession with the Mapper.""" </del><ins>+ """return a mapper() function which associates this ScopedSession with the Mapper. + + DEPRECATED. + + """ </ins><span class="cx"> </span><span class="cx"> from sqlalchemy.orm import mapper </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunktestexttest_declarativepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/ext/test_declarative.py (6081 => 6082)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/ext/test_declarative.py 2009-06-28 23:13:12 UTC (rev 6081) +++ sqlalchemy/trunk/test/ext/test_declarative.py 2009-07-03 15:31:29 UTC (rev 6082) </span><span class="lines">@@ -398,6 +398,7 @@ </span><span class="cx"> Address(email='two'), </span><span class="cx"> ])]) </span><span class="cx"> </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> def test_custom_mapper(self): </span><span class="cx"> class MyExt(sa.orm.MapperExtension): </span><span class="cx"> def create_instance(self): </span></span></pre></div> <a id="sqlalchemytrunktestormtest_scopingpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/test/orm/test_scoping.py (6081 => 6082)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/test/orm/test_scoping.py 2009-06-28 23:13:12 UTC (rev 6081) +++ sqlalchemy/trunk/test/orm/test_scoping.py 2009-07-03 15:31:29 UTC (rev 6082) </span><span class="lines">@@ -96,6 +96,7 @@ </span><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> @classmethod </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> @testing.resolve_artifact_names </span><span class="cx"> def setup_mappers(cls): </span><span class="cx"> Session = scoped_session(sa.orm.create_session) </span><span class="lines">@@ -122,6 +123,7 @@ </span><span class="cx"> sso = SomeOtherObject.query().first() </span><span class="cx"> assert SomeObject.query.filter_by(id=1).one().options[0].id == sso.id </span><span class="cx"> </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> @testing.resolve_artifact_names </span><span class="cx"> def test_query_compiles(self): </span><span class="cx"> class Foo(object): </span><span class="lines">@@ -141,6 +143,7 @@ </span><span class="cx"> Session.mapper(Baz, table2, extension=ext) </span><span class="cx"> assert hasattr(Baz, 'query') </span><span class="cx"> </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> @testing.resolve_artifact_names </span><span class="cx"> def test_default_constructor_state_not_shared(self): </span><span class="cx"> scope = scoped_session(sa.orm.sessionmaker()) </span><span class="lines">@@ -171,6 +174,7 @@ </span><span class="cx"> assert_raises(TypeError, C, foo='bar') </span><span class="cx"> D(foo='bar') </span><span class="cx"> </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> @testing.resolve_artifact_names </span><span class="cx"> def test_validating_constructor(self): </span><span class="cx"> s2 = SomeObject(someid=12) </span><span class="lines">@@ -183,6 +187,7 @@ </span><span class="cx"> assert_raises(sa.exc.ArgumentError, ValidatedOtherObject, </span><span class="cx"> someid=12, bogus=345) </span><span class="cx"> </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> @testing.resolve_artifact_names </span><span class="cx"> def test_dont_clobber_methods(self): </span><span class="cx"> class MyClass(object): </span><span class="lines">@@ -215,6 +220,7 @@ </span><span class="cx"> pass </span><span class="cx"> </span><span class="cx"> @classmethod </span><ins>+ @testing.uses_deprecated() </ins><span class="cx"> @testing.resolve_artifact_names </span><span class="cx"> def setup_mappers(cls): </span><span class="cx"> Session = scoped_session(sa.orm.sessionmaker()) </span></span></pre> </div> </div> </body> </html> |