[data hook] new .union operation on DataOperationMixIn, only when container is a set, not a list stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 14 Jun 2011 11:54:41 +0200
branchstable
changeset 7498 dc823b9ce74b
parent 7495 09d245a9bf5f
child 7499 96412cfc28e2
[data hook] new .union operation on DataOperationMixIn, only when container is a set, not a list
server/hook.py
--- a/server/hook.py	Fri Jun 10 17:21:17 2011 +0200
+++ b/server/hook.py	Tue Jun 14 11:54:41 2011 +0200
@@ -852,6 +852,13 @@
     def _build_container(self):
         return self.containercls()
 
+    def union(self, data):
+        """only when container is a set"""
+        assert not self._processed, """Trying to add data to a closed operation.
+Iterating over operation data closed it and should be reserved to precommit /
+postcommit method of the operation."""
+        self._container |= data
+
     def add_data(self, data):
         assert not self._processed, """Trying to add data to a closed operation.
 Iterating over operation data closed it and should be reserved to precommit /