[cwprops, migration] fix [set_]property to ensure we don't retrieve a user specific value. Add some docstring along the way
--- a/server/migractions.py Fri Mar 25 12:43:57 2011 +0100
+++ b/server/migractions.py Fri Mar 25 12:51:20 2011 +0100
@@ -1307,20 +1307,32 @@
# CWProperty handling ######################################################
def cmd_property_value(self, pkey):
- rql = 'Any V WHERE X is CWProperty, X pkey %(k)s, X value V'
- rset = self.rqlexec(rql, {'k': pkey}, ask_confirm=False)
+ """retreive the site-wide persistent property value for the given key.
+
+ To get a user specific property value, use appropriate method on CWUser
+ instance.
+ """
+ rset = self.rqlexec(
+ 'Any V WHERE X is CWProperty, X pkey %(k)s, X value V, NOT X for_user U',
+ {'k': pkey}, ask_confirm=False)
return rset[0][0]
def cmd_set_property(self, pkey, value):
+ """set the site-wide persistent property value for the given key to the
+ given value.
+
+ To set a user specific property value, use appropriate method on CWUser
+ instance.
+ """
value = unicode(value)
try:
- prop = self.rqlexec('CWProperty X WHERE X pkey %(k)s', {'k': pkey},
- ask_confirm=False).get_entity(0, 0)
+ prop = self.rqlexec(
+ 'CWProperty X WHERE X pkey %(k)s, NOT X for_user U',
+ {'k': pkey}, ask_confirm=False).get_entity(0, 0)
except:
self.cmd_create_entity('CWProperty', pkey=unicode(pkey), value=value)
else:
- self.rqlexec('SET X value %(v)s WHERE X pkey %(k)s',
- {'k': pkey, 'v': value}, ask_confirm=False)
+ prop.set_attributes(value=value)
# other data migration commands ###########################################