From: Mike Bayer Date: Mon, 23 Jul 2007 22:44:12 +0000 (+0000) Subject: removed methods instance_key(), identity_key(), identity() X-Git-Tag: rel_0_4_6~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd197001616f0070ab82dc621362bbcbd08065d7;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git removed methods instance_key(), identity_key(), identity() --- diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 555c1990e5..62b4d7d896 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1044,21 +1044,6 @@ class Mapper(object): else: return instance.__class__ is self.class_ - def instance_key(self, instance): - """Deprecated. A synonym for `identity_key_from_instance`.""" - - return self.identity_key_from_instance(instance) - - def identity_key(self, primary_key): - """Deprecated. A synonym for `identity_key_from_primary_key`.""" - - return self.identity_key_from_primary_key(primary_key) - - def identity(self, instance): - """Deprecated. A synoynm for `primary_key_from_instance`.""" - - return self.primary_key_from_instance(instance) - def _getpropbycolumn(self, column, raiseerror=True): try: prop = self.columntoproperty[column] @@ -1080,7 +1065,6 @@ class Mapper(object): prop = self._getpropbycolumn(column, raiseerror) if prop is None: return NO_ATTRIBUTE - #print "get column attribute '%s' from instance %s" % (column.key, mapperutil.instance_str(obj)) return prop.getattr(obj, column) def set_attr_by_column(self, obj, column, value): @@ -1127,7 +1111,7 @@ class Mapper(object): # and another instance with the same identity key already exists as persistent. convert to an # UPDATE if so. mapper = object_mapper(obj) - instance_key = mapper.instance_key(obj) + instance_key = mapper.identity_key_from_instance(obj) is_row_switch = not postupdate and not has_identity(obj) and instance_key in uowtransaction.uow.identity_map if is_row_switch: existing = uowtransaction.uow.identity_map[instance_key] @@ -1157,7 +1141,7 @@ class Mapper(object): mapper = object_mapper(obj) if table not in mapper.tables or not mapper._has_pks(table): continue - instance_key = mapper.instance_key(obj) + instance_key = mapper.identity_key_from_instance(obj) if self.__should_log_debug: self.__log_debug("save_obj() table '%s' instance %s identity %s" % (table.name, mapperutil.instance_str(obj), str(instance_key))) @@ -1654,7 +1638,7 @@ class Mapper(object): def post_execute(instance, **flags): self.__log_debug("Post query loading instance " + mapperutil.instance_str(instance)) - identitykey = self.instance_key(instance) + identitykey = self.identity_key_from_instance(instance) params = {} for c in param_names: diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index a774ce0778..216a1e7b4e 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -78,7 +78,7 @@ class Query(object): if hasattr(ident, '__colset__'): ident = ident.__colset__() - key = self.mapper.identity_key(ident) + key = self.mapper.identity_key_from_primary_key(ident) return self._get(key, ident, **kwargs) def load(self, ident, **kwargs): @@ -95,7 +95,7 @@ class Query(object): ret = self._extension.load(self, ident, **kwargs) if ret is not mapper.EXT_PASS: return ret - key = self.mapper.identity_key(ident) + key = self.mapper.identity_key_from_primary_key(ident) instance = self._get(key, ident, reload=True, **kwargs) if instance is None: raise exceptions.InvalidRequestError("No instance found for identity %s" % repr(ident)) diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index 46770b5211..3f41d3f35b 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -134,7 +134,7 @@ class UnitOfWork(object): self.new.remove(obj) if not hasattr(obj, '_instance_key'): mapper = object_mapper(obj) - obj._instance_key = mapper.instance_key(obj) + obj._instance_key = mapper.identity_key_from_instance(obj) if hasattr(obj, '_sa_insert_order'): delattr(obj, '_sa_insert_order') self.identity_map[obj._instance_key] = obj diff --git a/test/orm/unitofwork.py b/test/orm/unitofwork.py index eb39549eea..ae626db849 100644 --- a/test/orm/unitofwork.py +++ b/test/orm/unitofwork.py @@ -932,8 +932,7 @@ class SaveTest(UnitOfWorkTest): u.email = 'multi@test.org' ctx.current.flush() - id = m.identity(u) - print id + id = m.primary_key_from_instance(u) ctx.current.clear() @@ -1409,7 +1408,6 @@ class ManyToManyTest(UnitOfWorkTest): k.user_name = 'keyworduser' k.keyword_name = 'a keyword' ctx.current.flush() - print m.instance_key(k) id = (k.user_id, k.keyword_id) ctx.current.clear()