summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-08-15 15:13:13 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-08-15 15:13:13 -0400
commit652a24f0303b9bb0e7a326b05709d7660793f90b (patch)
tree03e06b27403ae76d12fbd564291a52ae5f35f0f1 /lib/sqlalchemy/orm
parent5a68f856daee59caf4c9da7d06880eada9d70302 (diff)
downloadsqlalchemy-652a24f0303b9bb0e7a326b05709d7660793f90b.tar.gz
- The :class:`.IdentityMap` exposed from :class:`.Session.identity`
now returns lists for ``items()`` and ``values()`` in Py3K. Early porting to Py3K here had these returning iterators, when they technically should be "iterable views"..for now, lists are OK.
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/identity.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py
index d9cdd791f..4425fc3a6 100644
--- a/lib/sqlalchemy/orm/identity.py
+++ b/lib/sqlalchemy/orm/identity.py
@@ -150,7 +150,7 @@ class WeakInstanceDict(IdentityMap):
return default
return o
- def _items(self):
+ def items(self):
values = self.all_states()
result = []
for state in values:
@@ -159,7 +159,7 @@ class WeakInstanceDict(IdentityMap):
result.append((state.key, value))
return result
- def _values(self):
+ def values(self):
values = self.all_states()
result = []
for state in values:
@@ -169,9 +169,10 @@ class WeakInstanceDict(IdentityMap):
return result
+ def __iter__(self):
+ return iter(self.keys())
+
if util.py2k:
- items = _items
- values = _values
def iteritems(self):
return iter(self.items())
@@ -179,24 +180,8 @@ class WeakInstanceDict(IdentityMap):
def itervalues(self):
return iter(self.values())
- def __iter__(self):
- return iter(self.keys())
-
- else:
- def items(self):
- return iter(self._items())
-
- def values(self):
- return iter(self._values())
-
- def __iter__(self):
- return self.keys()
-
def all_states(self):
- if util.py2k:
- return self._dict.values()
- else:
- return list(self._dict.values())
+ return self._dict.values()
def discard(self, state):
if state.key in self._dict:
@@ -217,11 +202,8 @@ class StrongInstanceDict(IdentityMap):
def iteritems(self):
return self._dict.iteritems()
- def __iter__(self):
- return iter(self.keys())
- else:
- def __iter__(self):
- return self.keys()
+ def __iter__(self):
+ return iter(self.dict_)
def __getitem__(self, key):
return self._dict[key]