[cwuser, persistent properties] fix recent set_property implementation on CWUser: for_user is automatically handled for non-managers users (this is seriously debatable though) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 28 Mar 2011 16:42:46 +0200
branchstable
changeset 7120 e8b6fc55df2d
parent 7119 8b29c4c2ffc6
child 7121 c2badb6de3fe
[cwuser, persistent properties] fix recent set_property implementation on CWUser: for_user is automatically handled for non-managers users (this is seriously debatable though)
entities/authobjs.py
--- a/entities/authobjs.py	Mon Mar 28 16:41:36 2011 +0200
+++ b/entities/authobjs.py	Mon Mar 28 16:42:46 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -87,8 +87,10 @@
                 'CWProperty X WHERE X pkey %(k)s, X for_user U, U eid %(u)s',
                 {'k': pkey, 'u': self.eid}).get_entity(0, 0)
         except:
-            self._cw.create_entity('CWProperty', pkey=unicode(pkey),
-                                   value=value, for_user=self)
+            kwargs = dict(pkey=unicode(pkey), value=value)
+            if self.is_in_group('managers'):
+                kwargs['for_user'] = self
+            self._cw.create_entity('CWProperty', **kwargs)
         else:
             prop.set_attributes(value=value)