entities/authobjs.py
branchstable
changeset 7110 73b3e0e095d3
parent 5556 9ab2b4c74baf
child 7120 e8b6fc55df2d
--- a/entities/authobjs.py	Tue Mar 22 15:11:38 2011 +0100
+++ b/entities/authobjs.py	Fri Mar 25 12:43:57 2011 +0100
@@ -80,6 +80,18 @@
                          key, self.login)
         return self._cw.vreg.property_value(key)
 
+    def set_property(self, pkey, value):
+        value = unicode(value)
+        try:
+            prop = self._cw.execute(
+                '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)
+        else:
+            prop.set_attributes(value=value)
+
     def matching_groups(self, groups):
         """return the number of the given group(s) in which the user is