[Sqlalchemy-commits] [1264] sqlalchemy/trunk/test: mapper's querying facilities migrated to new quer
Brought to you by:
zzzeek
<!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><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 { 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; } #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>[1264] sqlalchemy/trunk/test: mapper's querying facilities migrated to new query.Query() object, which can receive session-specific context via the mapper.using() statement.</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1264</dd> <dt>Author</dt> <dd>zzzeek</dd> <dt>Date</dt> <dd>2006-04-06 16:12:00 -0500 (Thu, 06 Apr 2006)</dd> </dl> <h3>Log Message</h3> <pre>mapper's querying facilities migrated to new query.Query() object, which can receive session-specific context via the mapper.using() statement. reuslting object instances will be bound to this session, but query execution still handled by the SQLEngines implicit in the mapper's Table objects. session now propigates to the unitofwork UOWTransaction object, as well as mapper's save_obj/delete_obj via the UOWTransaction it receives. UOWTransaction explicitly calls the Session for the engine corresponding to each Mapper in the flush operation, although the Session does not yet affect the choice of engines used, and mapper save/delete is still using the Table's implicit SQLEngine. changed internal unitofwork commit() method to be called flush(). removed all references to 'engine' from mapper module, including adding insert/update specific SQLEngine methods such as last_inserted_ids, last_inserted_params, etc. to the returned ResultProxy so that Mapper need not know which SQLEngine was used for the execute. changes to unit tests, SelectResults to support the new Query object.</pre> <h3>Modified Paths</h3> <ul> <li><a href="#sqlalchemytrunkdocbuildcontentdocstringsmyt">sqlalchemy/trunk/doc/build/content/docstrings.myt</a></li> <li><a href="#sqlalchemytrunklibsqlalchemy__init__py">sqlalchemy/trunk/lib/sqlalchemy/__init__.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemyenginepy">sqlalchemy/trunk/lib/sqlalchemy/engine.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemymappingmapperpy">sqlalchemy/trunk/lib/sqlalchemy/mapping/mapper.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemymappingobjectstorepy">sqlalchemy/trunk/lib/sqlalchemy/mapping/objectstore.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemymappingpropertiespy">sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemymappingunitofworkpy">sqlalchemy/trunk/lib/sqlalchemy/mapping/unitofwork.py</a></li> <li><a href="#sqlalchemytrunklibsqlalchemymodsselectresultspy">sqlalchemy/trunk/lib/sqlalchemy/mods/selectresults.py</a></li> <li><a href="#sqlalchemytrunktestmapperpy">sqlalchemy/trunk/test/mapper.py</a></li> <li><a href="#sqlalchemytrunktestobjectstorepy">sqlalchemy/trunk/test/objectstore.py</a></li> </ul> <h3>Added Paths</h3> <ul> <li><a href="#sqlalchemytrunklibsqlalchemymappingquerypy">sqlalchemy/trunk/lib/sqlalchemy/mapping/query.py</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="sqlalchemytrunkdocbuildcontentdocstringsmyt"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/doc/build/content/docstrings.myt (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/doc/build/content/docstrings.myt 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/doc/build/content/docstrings.myt 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -17,6 +17,7 @@ </span><span class="cx"> <& pydoc.myt:obj_doc, obj=sql, classes=[sql.ClauseParameters, sql.Compiled, sql.ClauseElement, sql.TableClause, sql.ColumnClause] &> </span><span class="cx"> <& pydoc.myt:obj_doc, obj=pool, classes=[pool.DBProxy, pool.Pool, pool.QueuePool, pool.SingletonThreadPool] &> </span><span class="cx"> <& pydoc.myt:obj_doc, obj=mapping, classes=[mapping.Mapper, mapping.MapperExtension] &> </span><ins>+<& pydoc.myt:obj_doc, obj=mapping.query, classes=[mapping.query.Query] &> </ins><span class="cx"> <& pydoc.myt:obj_doc, obj=mapping.objectstore, classes=[mapping.objectstore.Session, mapping.objectstore.Session.SessionTrans] &> </span><span class="cx"> <& pydoc.myt:obj_doc, obj=exceptions &> </span><span class="cx"> <& pydoc.myt:obj_doc, obj=proxy &> </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemy__init__py"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/__init__.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/__init__.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/__init__.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -9,8 +9,9 @@ </span><span class="cx"> from sql import * </span><span class="cx"> from schema import * </span><span class="cx"> from exceptions import * </span><del>-import mapping as mapperlib -from mapping import * </del><ins>+import sqlalchemy.sql +import sqlalchemy.mapping as mapping +from sqlalchemy.mapping import * </ins><span class="cx"> import sqlalchemy.schema </span><span class="cx"> import sqlalchemy.ext.proxy </span><span class="cx"> sqlalchemy.schema.default_engine = sqlalchemy.ext.proxy.ProxyEngine() </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemyenginepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/engine.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/engine.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/engine.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -817,6 +817,17 @@ </span><span class="cx"> raise StopIteration </span><span class="cx"> else: </span><span class="cx"> yield row </span><ins>+ + def last_inserted_ids(self): + return self.engine.last_inserted_ids() + def last_updated_params(self): + return self.engine.last_updated_params() + def last_inserted_params(self): + return self.engine.last_inserted_params() + def lastrow_has_defaults(self): + return self.engine.lastrow_has_defaults() + def supports_sane_rowcount(self): + return self.engine.supports_sane_rowcount() </ins><span class="cx"> </span><span class="cx"> def fetchall(self): </span><span class="cx"> """fetches all rows, just like DBAPI cursor.fetchall().""" </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemymappingmapperpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/mapping/mapper.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/mapping/mapper.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/mapping/mapper.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -7,11 +7,11 @@ </span><span class="cx"> </span><span class="cx"> import sqlalchemy.sql as sql </span><span class="cx"> import sqlalchemy.schema as schema </span><del>-import sqlalchemy.engine as engine </del><span class="cx"> import sqlalchemy.util as util </span><span class="cx"> import util as mapperutil </span><span class="cx"> import sync </span><span class="cx"> from sqlalchemy.exceptions import * </span><ins>+import query </ins><span class="cx"> import objectstore </span><span class="cx"> import sys </span><span class="cx"> import weakref </span><span class="lines">@@ -205,10 +205,6 @@ </span><span class="cx"> proplist = self.columntoproperty.setdefault(column.original, []) </span><span class="cx"> proplist.append(prop) </span><span class="cx"> </span><del>- self._get_clause = sql.and_() - for primary_key in self.pks_by_table[self.table]: - self._get_clause.clauses.append(primary_key == sql.bindparam("pk_"+primary_key.key)) - </del><span class="cx"> if not mapper_registry.has_key(self.class_key) or self.is_primary or (inherits is not None and inherits._is_primary_mapper()): </span><span class="cx"> objectstore.global_attributes.reset_class_managed(self.class_) </span><span class="cx"> self._init_class() </span><span class="lines">@@ -229,9 +225,75 @@ </span><span class="cx"> #print "mapper %s, columntoproperty:" % (self.class_.__name__) </span><span class="cx"> #for key, value in self.columntoproperty.iteritems(): </span><span class="cx"> # print key.table.name, key.key, [(v.key, v) for v in value] </span><del>- - engines = property(lambda s: [t.engine for t in s.tables]) </del><span class="cx"> </span><ins>+ def _get_query(self): + try: + if self._query.mapper is not self: + self._query = query.Query(self) + return self._query + except AttributeError: + self._query = query.Query(self) + return self._query + query = property(_get_query, doc=\ + """returns an instance of sqlalchemy.mapping.query.Query, which implements all the query-constructing + methods such as get(), select(), select_by(), etc. The default Query object uses the global thread-local + Session from the objectstore package. To get a Query object for a specific Session, call the + using(session) method.""") + + def get(self, *ident, **kwargs): + """calls get() on this mapper's default Query object.""" + return self.query.get(*ident, **kwargs) + + def _get(self, key, ident=None, reload=False): + return self.query._get(key, ident=ident, reload=reload) + + def get_by(self, *args, **params): + """calls get_by() on this mapper's default Query object.""" + return self.query.get_by(*args, **params) + + def select_by(self, *args, **params): + """calls select_by() on this mapper's default Query object.""" + return self.query.select_by(*args, **params) + + def selectfirst_by(self, *args, **params): + """calls selectfirst_by() on this mapper's default Query object.""" + return self.query.selectfirst_by(*args, **params) + + def selectone_by(self, *args, **params): + """calls selectone_by() on this mapper's default Query object.""" + return self.query.selectone_by(*args, **params) + + def count_by(self, *args, **params): + """calls count_by() on this mapper's default Query object.""" + return self.query.count_by(*args, **params) + + def selectfirst(self, *args, **params): + """calls selectfirst() on this mapper's default Query object.""" + return self.query.selectfirst(*args, **params) + + def selectone(self, *args, **params): + """calls selectone() on this mapper's default Query object.""" + return self.query.selectone(*args, **params) + + def select(self, arg=None, **kwargs): + """calls select() on this mapper's default Query object.""" + return self.query.select(arg=arg, **kwargs) + + def select_whereclause(self, whereclause=None, params=None, **kwargs): + """calls select_whereclause() on this mapper's default Query object.""" + return self.query.select_whereclause(whereclause=whereclause, params=params, **kwargs) + + def count(self, whereclause=None, params=None, **kwargs): + """calls count() on this mapper's default Query object.""" + return self.query.count(whereclause=whereclause, params=params, **kwargs) + + def select_statement(self, statement, **params): + """calls select_statement() on this mapper's default Query object.""" + return self.query.select_statement(statement, **params) + + def select_text(self, text, **params): + return self.query.select_text(text, **params) + </ins><span class="cx"> def add_property(self, key, prop): </span><span class="cx"> """adds an additional property to this mapper. this is the same as if it were </span><span class="cx"> specified within the 'properties' argument to the constructor. if the named </span><span class="lines">@@ -293,12 +355,18 @@ </span><span class="cx"> mapper_registry[self.class_key] = self </span><span class="cx"> if self.entity_name is None: </span><span class="cx"> self.class_.c = self.c </span><ins>+ + def has_eager(self): + """returns True if one of the properties attached to this Mapper is eager loading""" + return getattr(self, '_has_eager', False) </ins><span class="cx"> </span><span class="cx"> def set_property(self, key, prop): </span><span class="cx"> self.props[key] = prop </span><span class="cx"> prop.init(key, self) </span><span class="cx"> </span><span class="cx"> def instances(self, cursor, *mappers, **kwargs): </span><ins>+ """given a cursor (ResultProxy) from an SQLEngine, returns a list of object instances + corresponding to the rows in the cursor.""" </ins><span class="cx"> limit = kwargs.get('limit', None) </span><span class="cx"> offset = kwargs.get('offset', None) </span><span class="cx"> session = kwargs.get('session', None) </span><span class="lines">@@ -330,38 +398,7 @@ </span><span class="cx"> if mappers: </span><span class="cx"> result = [result] + otherresults </span><span class="cx"> return result </span><del>- - def get(self, *ident, **kwargs): - """returns an instance of the object based on the given identifier, or None - if not found. The *ident argument is a - list of primary key columns in the order of the table def's primary key columns.""" - key = objectstore.get_id_key(ident, self.class_, self.entity_name) - #print "key: " + repr(key) + " ident: " + repr(ident) - return self._get(key, ident, **kwargs) </del><span class="cx"> </span><del>- def _get(self, key, ident=None, reload=False, session=None): - if not reload and not self.always_refresh: - try: - if session is None: - session = objectstore.get_session() - return session._get(key) - except KeyError: - pass - - if ident is None: - ident = key[1] - i = 0 - params = {} - for primary_key in self.pks_by_table[self.table]: - params["pk_"+primary_key.key] = ident[i] - i += 1 - try: - statement = self._compile(self._get_clause) - return self._select_statement(statement, params=params, populate_existing=reload, session=session)[0] - except IndexError: - return None - - </del><span class="cx"> def identity_key(self, *primary_key): </span><span class="cx"> """returns the instance key for the given identity value. this is a global tracking object used by the objectstore, and is usually available off a mapped object as instance._instance_key.""" </span><span class="cx"> return objectstore.get_id_key(tuple(primary_key), self.class_, self.entity_name) </span><span class="lines">@@ -377,7 +414,7 @@ </span><span class="cx"> def compile(self, whereclause = None, **options): </span><span class="cx"> """works like select, except returns the SQL statement object without </span><span class="cx"> compiling or executing it""" </span><del>- return self._compile(whereclause, **options) </del><ins>+ return self.query._compile(whereclause, **options) </ins><span class="cx"> </span><span class="cx"> def copy(self, **kwargs): </span><span class="cx"> mapper = Mapper.__new__(Mapper) </span><span class="lines">@@ -387,22 +424,11 @@ </span><span class="cx"> return mapper </span><span class="cx"> </span><span class="cx"> def using(self, session): </span><del>- """returns a proxying object to this mapper, which will execute methods on the mapper - within the context of the given session. The session is placed as the "current" session - via the push_session/pop_session methods in the objectstore module.""" </del><ins>+ """returns a new Query object with the given Session.""" </ins><span class="cx"> if objectstore.get_session() is session: </span><del>- return self - mapper = self - class Proxy(object): - def __getattr__(self, key): - def callit(*args, **kwargs): - objectstore.push_session(session) - try: - return getattr(mapper, key)(*args, **kwargs) - finally: - objectstore.pop_session() - return callit - return Proxy() </del><ins>+ return self.query + else: + return query.Query(self, session=session) </ins><span class="cx"> </span><span class="cx"> def options(self, *options, **kwargs): </span><span class="cx"> """uses this mapper as a prototype for a new mapper with different behavior. </span><span class="lines">@@ -418,169 +444,12 @@ </span><span class="cx"> self._options[optkey] = mapper </span><span class="cx"> return mapper </span><span class="cx"> </span><del>- def get_by(self, *args, **params): - """returns a single object instance based on the given key/value criterion. - this is either the first value in the result list, or None if the list is - empty. - - the keys are mapped to property or column names mapped by this mapper's Table, and the values - are coerced into a WHERE clause separated by AND operators. If the local property/column - names dont contain the key, a search will be performed against this mapper's immediate - list of relations as well, forming the appropriate join conditions if a matching property - is located. - - e.g. u = usermapper.get_by(user_name = 'fred') - """ - x = self.select_whereclause(self._by_clause(*args, **params), limit=1) - if x: - return x[0] - else: - return None - - def select_by(self, *args, **params): - """returns an array of object instances based on the given clauses and key/value criterion. - - *args is a list of zero or more ClauseElements which will be connected by AND operators. - **params is a set of zero or more key/value parameters which are converted into ClauseElements. - the keys are mapped to property or column names mapped by this mapper's Table, and the values - are coerced into a WHERE clause separated by AND operators. If the local property/column - names dont contain the key, a search will be performed against this mapper's immediate - list of relations as well, forming the appropriate join conditions if a matching property - is located. - - e.g. result = usermapper.select_by(user_name = 'fred') - """ - ret = self.extension.select_by(self, *args, **params) - if ret is not EXT_PASS: - return ret - return self.select_whereclause(self._by_clause(*args, **params)) - - def selectfirst_by(self, *args, **params): - """works like select_by(), but only returns the first result by itself, or None if no - objects returned. Synonymous with get_by()""" - return self.get_by(*args, **params) - - def selectone_by(self, *args, **params): - """works like selectfirst_by(), but throws an error if not exactly one result was returned.""" - ret = mapper.select_whereclause(self._by_clause(*args, **params), limit=2) - if len(ret) == 1: - return ret[0] - raise InvalidRequestError('Multiple rows returned for selectone_by') - - def count_by(self, *args, **params): - """returns the count of instances based on the given clauses and key/value criterion. - The criterion is constructed in the same way as the select_by() method.""" - return self.count(self._by_clause(*args, **params)) - - def _by_clause(self, *args, **params): - clause = None - for arg in args: - if clause is None: - clause = arg - else: - clause &= arg - for key, value in params.iteritems(): - if value is False: - continue - c = self._get_criterion(key, value) - if c is None: - raise InvalidRequestError("Cant find criterion for property '"+ key + "'") - if clause is None: - clause = c - else: - clause &= c - return clause - - def _get_criterion(self, key, value): - """used by select_by to match a key/value pair against - local properties, column names, or a matching property in this mapper's - list of relations.""" - if self.props.has_key(key): - return self.props[key].columns[0] == value - elif self.table.c.has_key(key): - return self.table.c[key] == value - else: - for prop in self.props.values(): - c = prop.get_criterion(key, value) - if c is not None: - return c - else: - return None - </del><span class="cx"> def __getattr__(self, key): </span><del>- if (key.startswith('select_by_')): - key = key[10:] - def foo(arg): - return self.select_by(**{key:arg}) - return foo - elif (key.startswith('get_by_')): - key = key[7:] - def foo(arg): - return self.get_by(**{key:arg}) - return foo </del><ins>+ if (key.startswith('select_by_') or key.startswith('get_by_')): + return getattr(self.query, key) </ins><span class="cx"> else: </span><span class="cx"> raise AttributeError(key) </span><del>- - def selectfirst(self, *args, **params): - """works like select(), but only returns the first result by itself, or None if no - objects returned.""" - params['limit'] = 1 - ret = self.select_whereclause(*args, **params) - if ret: - return ret[0] - else: - return None </del><span class="cx"> </span><del>- def selectone(self, *args, **params): - """works like selectfirst(), but throws an error if not exactly one result was returned.""" - ret = list(self.select(*args, **params)[0:2]) - if len(ret) == 1: - return ret[0] - raise InvalidRequestError('Multiple rows returned for selectone') - - def select(self, arg=None, **kwargs): - """selects instances of the object from the database. - - arg can be any ClauseElement, which will form the criterion with which to - load the objects. - - For more advanced usage, arg can also be a Select statement object, which - will be executed and its resulting rowset used to build new object instances. - in this case, the developer must insure that an adequate set of columns exists in the - rowset with which to build new object instances.""" - - ret = self.extension.select(self, arg=arg, **kwargs) - if ret is not EXT_PASS: - return ret - elif arg is not None and isinstance(arg, sql.Selectable): - return self.select_statement(arg, **kwargs) - else: - return self.select_whereclause(whereclause=arg, **kwargs) - - def select_whereclause(self, whereclause=None, params=None, session=None, **kwargs): - statement = self._compile(whereclause, **kwargs) - return self._select_statement(statement, params=params, session=session) - - def count(self, whereclause=None, params=None, **kwargs): - s = self.table.count(whereclause) - if params is not None: - return s.scalar(**params) - else: - return s.scalar() - - def select_statement(self, statement, **params): - return self._select_statement(statement, params=params) - - def select_text(self, text, **params): - t = sql.text(text, engine=self.primarytable.engine) - return self.instances(t.execute(**params)) - - def _select_statement(self, statement, params=None, **kwargs): - statement.use_labels = True - if params is None: - params = {} - return self.instances(statement.execute(**params), **kwargs) - </del><span class="cx"> def _getpropbycolumn(self, column, raiseerror=True): </span><span class="cx"> try: </span><span class="cx"> prop = self.columntoproperty[column.original] </span><span class="lines">@@ -604,7 +473,6 @@ </span><span class="cx"> </span><span class="cx"> def _setattrbycolumn(self, obj, column, value): </span><span class="cx"> self.columntoproperty[column.original][0].setattr(obj, value) </span><del>- </del><span class="cx"> </span><span class="cx"> def save_obj(self, objects, uow, postupdate=False): </span><span class="cx"> """called by a UnitOfWork object to save objects, which involves either an INSERT or </span><span class="lines">@@ -714,17 +582,17 @@ </span><span class="cx"> for rec in update: </span><span class="cx"> (obj, params) = rec </span><span class="cx"> c = statement.execute(params) </span><del>- self._postfetch(table, obj, table.engine.last_updated_params()) </del><ins>+ self._postfetch(table, obj, c, c.last_updated_params()) </ins><span class="cx"> self.extension.after_update(self, obj) </span><span class="cx"> rows += c.cursor.rowcount </span><del>- if table.engine.supports_sane_rowcount() and rows != len(update): </del><ins>+ if c.supports_sane_rowcount() and rows != len(update): </ins><span class="cx"> raise CommitError("ConcurrencyError - updated rowcount %d does not match number of objects updated %d" % (rows, len(update))) </span><span class="cx"> if len(insert): </span><span class="cx"> statement = table.insert() </span><span class="cx"> for rec in insert: </span><span class="cx"> (obj, params) = rec </span><del>- statement.execute(**params) - primary_key = table.engine.last_inserted_ids() </del><ins>+ c = statement.execute(**params) + primary_key = c.last_inserted_ids() </ins><span class="cx"> if primary_key is not None: </span><span class="cx"> i = 0 </span><span class="cx"> for col in self.pks_by_table[table]: </span><span class="lines">@@ -732,16 +600,16 @@ </span><span class="cx"> if self._getattrbycolumn(obj, col) is None: </span><span class="cx"> self._setattrbycolumn(obj, col, primary_key[i]) </span><span class="cx"> i+=1 </span><del>- self._postfetch(table, obj, table.engine.last_inserted_params()) </del><ins>+ self._postfetch(table, obj, c, c.last_inserted_params()) </ins><span class="cx"> if self._synchronizer is not None: </span><span class="cx"> self._synchronizer.execute(obj, obj) </span><span class="cx"> self.extension.after_insert(self, obj) </span><span class="cx"> </span><del>- def _postfetch(self, table, obj, params): - """after an INSERT or UPDATE, asks the engine if PassiveDefaults fired off on the database side </del><ins>+ def _postfetch(self, table, obj, resultproxy, params): + """after an INSERT or UPDATE, asks the returned result if PassiveDefaults fired off on the database side </ins><span class="cx"> which need to be post-fetched, *or* if pre-exec defaults like ColumnDefaults were fired off </span><span class="cx"> and should be populated into the instance. this is only for non-primary key columns.""" </span><del>- if table.engine.lastrow_has_defaults(): </del><ins>+ if resultproxy.lastrow_has_defaults(): </ins><span class="cx"> clause = sql.and_() </span><span class="cx"> for p in self.pks_by_table[table]: </span><span class="cx"> clause.clauses.append(p == self._getattrbycolumn(obj, p)) </span><span class="lines">@@ -785,7 +653,7 @@ </span><span class="cx"> clause.clauses.append(self.version_id_col == sql.bindparam(self.version_id_col.key)) </span><span class="cx"> statement = table.delete(clause) </span><span class="cx"> c = statement.execute(*delete) </span><del>- if table.engine.supports_sane_rowcount() and c.rowcount != len(delete): </del><ins>+ if c.supports_sane_rowcount() and c.rowcount != len(delete): </ins><span class="cx"> raise CommitError("ConcurrencyError - updated rowcount %d does not match number of objects updated %d" % (c.cursor.rowcount, len(delete))) </span><span class="cx"> </span><span class="cx"> def _has_pks(self, table): </span><span class="lines">@@ -811,53 +679,7 @@ </span><span class="cx"> for prop in self.props.values(): </span><span class="cx"> prop.register_deleted(obj, uow) </span><span class="cx"> </span><del>- def _should_nest(self, **kwargs): - """returns True if the given statement options indicate that we should "nest" the - generated query as a subquery inside of a larger eager-loading query. this is used - with keywords like distinct, limit and offset and the mapper defines eager loads.""" - return ( - getattr(self, '_has_eager', False) - and (kwargs.has_key('limit') or kwargs.has_key('offset') or kwargs.get('distinct', False)) - ) </del><span class="cx"> </span><del>- def _compile(self, whereclause = None, **kwargs): - order_by = kwargs.pop('order_by', False) - if order_by is False: - order_by = self.order_by - if order_by is False: - if self.table.default_order_by() is not None: - order_by = self.table.default_order_by() - - if self._should_nest(**kwargs): - s2 = sql.select(self.table.primary_key, whereclause, use_labels=True, from_obj=[self.table], **kwargs) -# raise "ok first thing", str(s2) - if not kwargs.get('distinct', False) and order_by: - s2.order_by(*util.to_list(order_by)) - s3 = s2.alias('rowcount') - crit = [] - for i in range(0, len(self.table.primary_key)): - crit.append(s3.primary_key[i] == self.table.primary_key[i]) - statement = sql.select([], sql.and_(*crit), from_obj=[self.table], use_labels=True) - # raise "OK statement", str(statement) - if order_by: - statement.order_by(*util.to_list(order_by)) - else: - statement = sql.select([], whereclause, from_obj=[self.table], use_labels=True, **kwargs) - if order_by: - statement.order_by(*util.to_list(order_by)) - # for a DISTINCT query, you need the columns explicitly specified in order - # to use it in "order_by". insure they are in the column criterion (particularly oid). - # TODO: this should be done at the SQL level not the mapper level - if kwargs.get('distinct', False) and order_by: - statement.append_column(*util.to_list(order_by)) - # plugin point - - - # give all the attached properties a chance to modify the query - for key, value in self.props.iteritems(): - value.setup(key, statement, **kwargs) - return statement - </del><span class="cx"> def _identity_key(self, row): </span><span class="cx"> return objectstore.get_row_key(row, self.class_, self.pks_by_table[self.table], self.entity_name) </span><span class="cx"> </span><span class="lines">@@ -1003,16 +825,18 @@ </span><span class="cx"> def chain(self, ext): </span><span class="cx"> self.next = ext </span><span class="cx"> return self </span><del>- def select_by(self, mapper, *args, **kwargs): </del><ins>+ def select_by(self, query, *args, **kwargs): + """overrides the select_by method of the Query object""" </ins><span class="cx"> if self.next is None: </span><span class="cx"> return EXT_PASS </span><span class="cx"> else: </span><del>- return self.next.select_by(mapper, *args, **kwargs) - def select(self, mapper, *args, **kwargs): </del><ins>+ return self.next.select_by(query, *args, **kwargs) + def select(self, query, *args, **kwargs): + """overrides the select method of the Query object""" </ins><span class="cx"> if self.next is None: </span><span class="cx"> return EXT_PASS </span><span class="cx"> else: </span><del>- return self.next.select(mapper, *args, **kwargs) </del><ins>+ return self.next.select(query, *args, **kwargs) </ins><span class="cx"> def create_instance(self, mapper, row, imap, class_): </span><span class="cx"> """called when a new object instance is about to be created from a row. </span><span class="cx"> the method can choose to create the instance itself, or it can return </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemymappingobjectstorepy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/mapping/objectstore.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/mapping/objectstore.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/mapping/objectstore.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -118,6 +118,9 @@ </span><span class="cx"> self.uow = unitofwork.UnitOfWork(identity_map = self.uow.identity_map) </span><span class="cx"> return Session.SessionTrans(self, self.uow, True) </span><span class="cx"> </span><ins>+ def engines(self, mapper): + return [t.engine for t in mapper.tables] + </ins><span class="cx"> def _trans_commit(self, trans): </span><span class="cx"> if trans.uow is self.uow and trans.isactive: </span><span class="cx"> try: </span><span class="lines">@@ -133,7 +136,7 @@ </span><span class="cx"> def _commit_uow(self, *obj): </span><span class="cx"> self.was_pushed() </span><span class="cx"> try: </span><del>- self.uow.commit(*obj) </del><ins>+ self.uow.flush(self, *obj) </ins><span class="cx"> finally: </span><span class="cx"> self.was_popped() </span><span class="cx"> </span><span class="lines">@@ -147,7 +150,7 @@ </span><span class="cx"> # change begin/commit status </span><span class="cx"> if len(objects): </span><span class="cx"> self._commit_uow(*objects) </span><del>- self.uow.commit(*objects) </del><ins>+ self.uow.flush(self, *objects) </ins><span class="cx"> return </span><span class="cx"> if self.parent_uow is None: </span><span class="cx"> self._commit_uow() </span><span class="lines">@@ -283,13 +286,13 @@ </span><span class="cx"> return get_session().import_instance(instance) </span><span class="cx"> </span><span class="cx"> def mapper(*args, **params): </span><del>- return sqlalchemy.mapperlib.mapper(*args, **params) </del><ins>+ return sqlalchemy.mapping.mapper(*args, **params) </ins><span class="cx"> </span><span class="cx"> def object_mapper(obj): </span><del>- return sqlalchemy.mapperlib.object_mapper(obj) </del><ins>+ return sqlalchemy.mapping.object_mapper(obj) </ins><span class="cx"> </span><span class="cx"> def class_mapper(class_): </span><del>- return sqlalchemy.mapperlib.class_mapper(class_) </del><ins>+ return sqlalchemy.mapping.class_mapper(class_) </ins><span class="cx"> </span><span class="cx"> global_attributes = unitofwork.global_attributes </span><span class="cx"> </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemymappingpropertiespy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/mapping/properties.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -582,7 +582,7 @@ </span><span class="cx"> (self.lazywhere, self.lazybinds) = create_lazy_clause(self.parent.noninherited_table, self.primaryjoin, self.secondaryjoin, self.foreignkey) </span><span class="cx"> # determine if our "lazywhere" clause is the same as the mapper's </span><span class="cx"> # get() clause. then we can just use mapper.get() </span><del>- self.use_get = not self.uselist and self.mapper._get_clause.compare(self.lazywhere) </del><ins>+ self.use_get = not self.uselist and self.mapper.query._get_clause.compare(self.lazywhere) </ins><span class="cx"> </span><span class="cx"> def _set_class_attribute(self, class_, key): </span><span class="cx"> # establish a class-level lazy loader on our class </span><span class="lines">@@ -609,14 +609,14 @@ </span><span class="cx"> ident = [] </span><span class="cx"> for primary_key in self.mapper.pks_by_table[self.mapper.table]: </span><span class="cx"> ident.append(params[primary_key._label]) </span><del>- return self.mapper.get(session=session, *ident) </del><ins>+ return self.mapper.using(session).get(*ident) </ins><span class="cx"> elif self.order_by is not False: </span><span class="cx"> order_by = self.order_by </span><span class="cx"> elif self.secondary is not None and self.secondary.default_order_by() is not None: </span><span class="cx"> order_by = self.secondary.default_order_by() </span><span class="cx"> else: </span><span class="cx"> order_by = False </span><del>- result = self.mapper.select_whereclause(self.lazywhere, order_by=order_by, params=params, session=session) </del><ins>+ result = self.mapper.using(session).select_whereclause(self.lazywhere, order_by=order_by, params=params) </ins><span class="cx"> else: </span><span class="cx"> result = [] </span><span class="cx"> if self.uselist: </span></span></pre></div> <a id="sqlalchemytrunklibsqlalchemymappingquerypy"></a> <div class="addfile"><h4>Added: sqlalchemy/trunk/lib/sqlalchemy/mapping/query.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/mapping/query.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/mapping/query.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -0,0 +1,267 @@ </span><ins>+ +import objectstore +import sqlalchemy.sql as sql +import sqlalchemy.util as util +import mapper + +class Query(object): + """encapsulates the object-fetching operations provided by Mappers.""" + def __init__(self, mapper, **kwargs): + self.mapper = mapper + self.always_refresh = kwargs.pop('always_refresh', self.mapper.always_refresh) + self.order_by = kwargs.pop('order_by', self.mapper.order_by) + self._session = kwargs.pop('session', None) + if not hasattr(mapper, '_get_clause'): + _get_clause = sql.and_() + for primary_key in self.mapper.pks_by_table[self.table]: + _get_clause.clauses.append(primary_key == sql.bindparam("pk_"+primary_key.key)) + self.mapper._get_clause = _get_clause + self._get_clause = self.mapper._get_clause + def _get_session(self): + if self._session is None: + return objectstore.get_session() + else: + return self._session + table = property(lambda s:s.mapper.table) + props = property(lambda s:s.mapper.props) + session = property(_get_session) + + def get(self, *ident, **kwargs): + """returns an instance of the object based on the given identifier, or None + if not found. The *ident argument is a + list of primary key columns in the order of the table def's primary key columns.""" + key = self.mapper.identity_key(*ident) + #print "key: " + repr(key) + " ident: " + repr(ident) + return self._get(key, ident, **kwargs) + + def get_by(self, *args, **params): + """returns a single object instance based on the given key/value criterion. + this is either the first value in the result list, or None if the list is + empty. + + the keys are mapped to property or column names mapped by this mapper's Table, and the values + are coerced into a WHERE clause separated by AND operators. If the local property/column + names dont contain the key, a search will be performed against this mapper's immediate + list of relations as well, forming the appropriate join conditions if a matching property + is located. + + e.g. u = usermapper.get_by(user_name = 'fred') + """ + x = self.select_whereclause(self._by_clause(*args, **params), limit=1) + if x: + return x[0] + else: + return None + + def select_by(self, *args, **params): + """returns an array of object instances based on the given clauses and key/value criterion. + + *args is a list of zero or more ClauseElements which will be connected by AND operators. + **params is a set of zero or more key/value parameters which are converted into ClauseElements. + the keys are mapped to property or column names mapped by this mapper's Table, and the values + are coerced into a WHERE clause separated by AND operators. If the local property/column + names dont contain the key, a search will be performed against this mapper's immediate + list of relations as well, forming the appropriate join conditions if a matching property + is located. + + e.g. result = usermapper.select_by(user_name = 'fred') + """ + ret = self.mapper.extension.select_by(self, *args, **params) + if ret is not mapper.EXT_PASS: + return ret + return self.select_whereclause(self._by_clause(*args, **params)) + + def selectfirst_by(self, *args, **params): + """works like select_by(), but only returns the first result by itself, or None if no + objects returned. Synonymous with get_by()""" + return self.get_by(*args, **params) + + def selectone_by(self, *args, **params): + """works like selectfirst_by(), but throws an error if not exactly one result was returned.""" + ret = self.select_whereclause(self._by_clause(*args, **params), limit=2) + if len(ret) == 1: + return ret[0] + raise InvalidRequestError('Multiple rows returned for selectone_by') + + def count_by(self, *args, **params): + """returns the count of instances based on the given clauses and key/value criterion. + The criterion is constructed in the same way as the select_by() method.""" + return self.count(self._by_clause(*args, **params)) + + def selectfirst(self, *args, **params): + """works like select(), but only returns the first result by itself, or None if no + objects returned.""" + params['limit'] = 1 + ret = self.select_whereclause(*args, **params) + if ret: + return ret[0] + else: + return None + + def selectone(self, *args, **params): + """works like selectfirst(), but throws an error if not exactly one result was returned.""" + ret = list(self.select(*args, **params)[0:2]) + if len(ret) == 1: + return ret[0] + raise InvalidRequestError('Multiple rows returned for selectone') + + def select(self, arg=None, **kwargs): + """selects instances of the object from the database. + + arg can be any ClauseElement, which will form the criterion with which to + load the objects. + + For more advanced usage, arg can also be a Select statement object, which + will be executed and its resulting rowset used to build new object instances. + in this case, the developer must insure that an adequate set of columns exists in the + rowset with which to build new object instances.""" + + ret = self.mapper.extension.select(self, arg=arg, **kwargs) + if ret is not mapper.EXT_PASS: + return ret + elif arg is not None and isinstance(arg, sql.Selectable): + return self.select_statement(arg, **kwargs) + else: + return self.select_whereclause(whereclause=arg, **kwargs) + + def select_whereclause(self, whereclause=None, params=None, **kwargs): + statement = self._compile(whereclause, **kwargs) + return self._select_statement(statement, params=params) + + def count(self, whereclause=None, params=None, **kwargs): + s = self.table.count(whereclause) + if params is not None: + return s.scalar(**params) + else: + return s.scalar() + + def select_statement(self, statement, **params): + return self._select_statement(statement, params=params) + + def select_text(self, text, **params): + t = sql.text(text, engine=self.mapper.primarytable.engine) + return self.instances(t.execute(**params)) + + def __getattr__(self, key): + if (key.startswith('select_by_')): + key = key[10:] + def foo(arg): + return self.select_by(**{key:arg}) + return foo + elif (key.startswith('get_by_')): + key = key[7:] + def foo(arg): + return self.get_by(**{key:arg}) + return foo + else: + raise AttributeError(key) + + def instances(self, *args, **kwargs): + return self.mapper.instances(session=self.session, *args, **kwargs) + + def _by_clause(self, *args, **params): + clause = None + for arg in args: + if clause is None: + clause = arg + else: + clause &= arg + for key, value in params.iteritems(): + if value is False: + continue + c = self._get_criterion(key, value) + if c is None: + raise InvalidRequestError("Cant find criterion for property '"+ key + "'") + if clause is None: + clause = c + else: + clause &= c + return clause + + def _get(self, key, ident=None, reload=False): + if not reload and not self.always_refresh: + try: + return self.session._get(key) + except KeyError: + pass + + if ident is None: + ident = key[1] + i = 0 + params = {} + for primary_key in self.mapper.pks_by_table[self.table]: + params["pk_"+primary_key.key] = ident[i] + i += 1 + try: + statement = self._compile(self._get_clause) + return self._select_statement(statement, params=params, populate_existing=reload)[0] + except IndexError: + return None + + def _select_statement(self, statement, params=None, **kwargs): + statement.use_labels = True + if params is None: + params = {} + return self.instances(statement.execute(**params), **kwargs) + + def _should_nest(self, **kwargs): + """returns True if the given statement options indicate that we should "nest" the + generated query as a subquery inside of a larger eager-loading query. this is used + with keywords like distinct, limit and offset and the mapper defines eager loads.""" + return ( + self.mapper.has_eager() + and (kwargs.has_key('limit') or kwargs.has_key('offset') or kwargs.get('distinct', False)) + ) + + def _compile(self, whereclause = None, **kwargs): + order_by = kwargs.pop('order_by', False) + if order_by is False: + order_by = self.order_by + if order_by is False: + if self.table.default_order_by() is not None: + order_by = self.table.default_order_by() + + if self._should_nest(**kwargs): + s2 = sql.select(self.table.primary_key, whereclause, use_labels=True, from_obj=[self.table], **kwargs) +# raise "ok first thing", str(s2) + if not kwargs.get('distinct', False) and order_by: + s2.order_by(*util.to_list(order_by)) + s3 = s2.alias('rowcount') + crit = [] + for i in range(0, len(self.table.primary_key)): + crit.append(s3.primary_key[i] == self.table.primary_key[i]) + statement = sql.select([], sql.and_(*crit), from_obj=[self.table], use_labels=True) + # raise "OK statement", str(statement) + if order_by: + statement.order_by(*util.to_list(order_by)) + else: + statement = sql.select([], whereclause, from_obj=[self.table], use_labels=True, **kwargs) + if order_by: + statement.order_by(*util.to_list(order_by)) + # for a DISTINCT query, you need the columns explicitly specified in order + # to use it in "order_by". insure they are in the column criterion (particularly oid). + # TODO: this should be done at the SQL level not the mapper level + if kwargs.get('distinct', False) and order_by: + statement.append_column(*util.to_list(order_by)) + # plugin point + + # give all the attached properties a chance to modify the query + for key, value in self.mapper.props.iteritems(): + value.setup(key, statement, **kwargs) + return statement + + def _get_criterion(self, key, value): + """used by select_by to match a key/value pair against + local properties, column names, or a matching property in this mapper's + list of relations.""" + if self.props.has_key(key): + return self.props[key].columns[0] == value + elif self.table.c.has_key(key): + return self.table.c[key] == value + else: + for prop in self.props.values(): + c = prop.get_criterion(key, value) + if c is not None: + return c + else: + return None </ins></span></pre></div> <a id="sqlalchemytrunklibsqlalchemymappingunitofworkpy"></a> <div class="modfile"><h4>Modified: sqlalchemy/trunk/lib/sqlalchemy/mapping/unitofwork.py (1263 => 1264)</h4> <pre class="diff"><span> <span class="info">--- sqlalchemy/trunk/lib/sqlalchemy/mapping/unitofwork.py 2006-04-06 19:25:58 UTC (rev 1263) +++ sqlalchemy/trunk/lib/sqlalchemy/mapping/unitofwork.py 2006-04-06 21:12:00 UTC (rev 1264) </span><span class="lines">@@ -5,13 +5,13 @@ </span><span class="cx"> # the MIT License: http://www.opensource.org/licenses/mit-license.php </span><span class="cx"> </span><span class="cx"> """the internals for the Unit Of Work system. includes hooks into the attributes package </span><del>-enabling the routing of change events to Unit Of Work objects, as well as the commit mechanism </del><ins>+enabling the routing of change events to Unit Of Work objects, as well as the flush() mechanism </ins><span class="cx"> which creates a dependency structure that executes change operations. </span><span class="cx"> </span><span class="cx"> a Unit of Work is essentially a system of maintaining a graph of in-memory objects and their </span><span class="cx"> modified state. Objects are maintained as unique against their primary key identity using </span><span class="cx"> an "identity map" pattern. The Unit of Work then maintains lists of objects that are new, </span><del>-dirty, or deleted and provides the capability to commit all those changes at once. </del><ins>+dirty, or deleted and provides the capability to flush all those changes at once. </ins><span class="cx"> """ </span><span class="cx"> </span><span class="cx"> from sqlalchemy import attributes </span><span class="lines">@@ -23,7 +23,7 @@ </span><span class="cx"> import topological </span><span class="cx"> from sets import * </span><span class="cx"> </span><del>-# a global indicating if all commit() operations should have their plan </del><ins>+# a global indicating if all flush() operations should have their plan </ins><span class="cx"> # printed to standard output. also can be affected by creating an engine </span><span class="cx"> # with the "echo_uow=True" keyword argument. </span><span class="cx"> LOG = False </span><span class="lines">@@ -73,7 +73,7 @@ </span><span class="cx"> return UOWListElement(obj, key, list_, **kwargs) </span><span class="cx"> </span><span class="cx"> class UnitOfWork(object): </span><del>- """main UOW object which stores lists of dirty/new/deleted objects, as well as 'modified_lists' for list attributes. provides top-level "commit" functionality as well as the transaction boundaries with the SQLEngine(s) involved in a write operation.""" </del><ins>+ """main UOW object which stores lists of dirty/new/deleted objects, as well as 'modified_lists' for list attributes. provides top-level "flush" functionality as well as the transaction boundaries with the SQLEngine(s) involved in a write operation.""" </ins><span class="cx"> def __init__(self, identity_map=None): </span><span class="cx"> if identity_map is not None: </span><span class="cx"> self.identity_map = identity_map </span><span class="lines">@@ -141,7 +141,7 @@ </span><span class="cx"> self.attributes.remove(obj) </span><span class="cx"> </span><span class="cx"> def _validate_obj(self, obj): </span><del>- """validates that dirty/delete/commit operations can occur upon the given object, by checking </del><ins>+ """validates that dirty/delete/flush operations can occur upon the given object, by checking </ins><span class="cx"> if it has an instance key and that the instance key is present in the identity map.""" </span><span class="cx"> if hasattr(obj, '_instance_key') and not self.identity_map.has_key(obj._instance_key): </span><span class="cx"> raise InvalidRequestError("Detected a mapped object not present in the current thread's Identity Map: '%s'. Use objectstore.import_instance() to place deserialized instances or instances from other threads" % repr(obj._instance_key)) </span><span class="lines">@@ -203,8 +203,8 @@ </span><span class="cx"> except KeyError: </span><span class="cx"> pass </span><span class="cx"> </span><del>- def commit(self, *objects): - commit_context = UOWTransaction(self) </del><ins>+ def flush(self, session, *objects): + flush_context = UOWTransaction(self, session) </ins><span class="cx"> </span><span class="cx"> if len(objects): </span><span class="cx"> objset = util.HashSet(iter=objects) </span><span class="lines">@@ -216,29 +216,29 @@ </span><span class="cx"> continue </span><span class="cx"> if self.deleted.contains(obj): </span><span class="cx"> continue </span><del>- commit_context.register_object(obj) </del><ins>+ flush_context.register_object(obj) </ins><span class="cx"> for item in self.modified_lists: </span><span class="cx"> obj = item.obj </span><span class="cx"> if objset is not None and not objset.contains(obj): </span><span class="cx"> continue </span><span class="cx"> if self.deleted.contains(obj): </span><span class="cx"> continue </span><del>- commit_context.register_object(obj, listonly = True) - commit_context.register_saved_history(item) </del><ins>+ flush_context.register_object(obj, listonly = True) + flush_context.register_saved_history(item) </ins><span class="cx"> </span><span class="cx"> # for o in item.added_items() + item.deleted_items(): </span><span class="cx"> # if self.deleted.contains(o): </span><span class="cx"> # cont... [truncated message content] |