]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add support for python3.3 list.clear() on orm.collections
authorschettino72 <schettino72@gmail.com>
Wed, 6 Nov 2013 09:52:40 +0000 (22:52 +1300)
committerschettino72 <schettino72@gmail.com>
Wed, 6 Nov 2013 09:52:40 +0000 (22:52 +1300)
lib/sqlalchemy/orm/collections.py

index 6bd5ac968e06057f52bbdbfd99f14c9faeced3e3..fd1677058ea220093e24bb90ead5b37d662ffe6f 100644 (file)
@@ -1161,6 +1161,15 @@ def _list_decorators():
         _tidy(pop)
         return pop
 
+    def clear(fn):
+        def clear(self, index=-1):
+            __before_delete(self)
+            for item in self:
+                __del(self, item)
+            fn(self)
+        _tidy(clear)
+        return clear
+
     # __imul__ : not wrapping this.  all members of the collection are already
     # present, so no need to fire appends... wrapping it with an explicit
     # decorator is still possible, so events on *= can be had if they're