[cwvreg] Fix propertyvalues hot updates
authorChristophe de Vienne <christophe@unlish.com>
Sat, 30 Jan 2016 23:06:18 +0100
changeset 11097 900c27ea30e9
parent 11054 aec47ca624b2
child 11118 0c645f09d96a
[cwvreg] Fix propertyvalues hot updates When CWProperty instances are touched, the corresponding value gets updated in vreg['propertyvalues'], but their type was ignored.
hooks/syncsession.py
hooks/test/unittest_syncsession.py
--- a/hooks/syncsession.py	Thu Jan 07 12:20:50 2016 +0100
+++ b/hooks/syncsession.py	Sat Jan 30 23:06:18 2016 +0100
@@ -148,7 +148,8 @@
         """the observed connections set has been commited"""
         cwprop = self.cwprop
         if not cwprop.for_user:
-            self.cnx.vreg['propertyvalues'][cwprop.pkey] = cwprop.value
+            self.cnx.vreg['propertyvalues'][cwprop.pkey] = \
+                self.cnx.vreg.typed_value(cwprop.pkey, cwprop.value)
         # if for_user is set, update is handled by a ChangeCWPropertyOp operation
 
 
--- a/hooks/test/unittest_syncsession.py	Thu Jan 07 12:20:50 2016 +0100
+++ b/hooks/test/unittest_syncsession.py	Sat Jan 30 23:06:18 2016 +0100
@@ -69,6 +69,15 @@
                 req.execute('INSERT CWProperty X: X pkey "ui.language", X value "hop"')
             self.assertEqual(cm.exception.errors, {'value-subject': u'unauthorized value'})
 
+    def test_vreg_propertyvalues_update(self):
+        self.vreg.register_property(
+            'test.int', type='Int', help='', sitewide=True)
+        with self.admin_access.repo_cnx() as cnx:
+            cnx.execute('INSERT CWProperty X: X pkey "test.int", X value "42"')
+            cnx.commit()
+        self.assertEqual(self.vreg.property_value('test.int'), 42)
+
+
 if __name__ == '__main__':
     from logilab.common.testlib import unittest_main
     unittest_main()