new _cw_unsafe argument to Entity.set_attributes until something nicer is done (eg #344874) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 17 Aug 2009 13:18:35 +0200
branchstable
changeset 2877 e469f3602858
parent 2876 b6993462ddb9
child 2878 03244a6d0283
new _cw_unsafe argument to Entity.set_attributes until something nicer is done (eg #344874)
entity.py
--- a/entity.py	Mon Aug 17 12:12:40 2009 +0200
+++ b/entity.py	Mon Aug 17 13:18:35 2009 +0200
@@ -834,7 +834,7 @@
 
     # raw edition utilities ###################################################
 
-    def set_attributes(self, **kwargs):
+    def set_attributes(self, _cw_unsafe=False, **kwargs):
         assert kwargs
         relations = []
         for key in kwargs:
@@ -843,8 +843,12 @@
         self.update(kwargs)
         # and now update the database
         kwargs['x'] = self.eid
-        self.req.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations),
-                         kwargs, 'x')
+        if _cw_unsafe:
+            self.req.unsafe_execute(
+                'SET %s WHERE X eid %%(x)s' % ','.join(relations), kwargs, 'x')
+        else:
+            self.req.execute('SET %s WHERE X eid %%(x)s' % ','.join(relations),
+                             kwargs, 'x')
 
     def delete(self):
         assert self.has_eid(), self.eid