summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-04-01 11:01:56 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-04-01 11:01:56 -0400
commit2563b33453dee1b55500f13421b7b50ba367a504 (patch)
tree24de4704b64d496297873bd84b9a1ca7ae658839 /lib/sqlalchemy
parent45046367f34ee2dadb98024b0f2b05248459f978 (diff)
downloadsqlalchemy-2563b33453dee1b55500f13421b7b50ba367a504.tar.gz
- [bug] Fixed bug which would prevent
OrderingList from being pickleable [ticket:2454]. Courtesy Jeff Dairiki
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/ext/orderinglist.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/orderinglist.py b/lib/sqlalchemy/ext/orderinglist.py
index 97be329e9..0a27ee309 100644
--- a/lib/sqlalchemy/ext/orderinglist.py
+++ b/lib/sqlalchemy/ext/orderinglist.py
@@ -314,9 +314,23 @@ class OrderingList(list):
self._reorder()
# end Py2K
+ def __reduce__(self):
+ return _reconstitute, (self.__class__, self.__dict__, list(self))
+
for func_name, func in locals().items():
if (util.callable(func) and func.func_name == func_name and
not func.__doc__ and hasattr(list, func_name)):
func.__doc__ = getattr(list, func_name).__doc__
del func_name, func
+def _reconstitute(cls, dict_, items):
+ """ Reconstitute an ``OrderingList``.
+
+ This is the adjoint to ``OrderingList.__reduce__()``. It is used for
+ unpickling ``OrderingList``\\s
+
+ """
+ obj = cls.__new__(cls)
+ obj.__dict__.update(dict_)
+ list.extend(obj, items)
+ return obj