[hook] use entity instead of values dict, check for edited_attributes on rtype change stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 08 Mar 2010 09:04:36 +0100
branchstable
changeset 4827 8a505bf12193
parent 4826 7eba168407c3
child 4828 3e173d598cad
[hook] use entity instead of values dict, check for edited_attributes on rtype change
hooks/syncschema.py
--- a/hooks/syncschema.py	Mon Mar 08 09:03:43 2010 +0100
+++ b/hooks/syncschema.py	Mon Mar 08 09:04:36 2010 +0100
@@ -226,7 +226,7 @@
 
 class SourceDbCWRTypeUpdate(hook.Operation):
     """actually update some properties of a relation definition"""
-    rschema = values = entity = None # make pylint happy
+    rschema = entity = None # make pylint happy
 
     def precommit_event(self):
         session = self.session
@@ -241,8 +241,7 @@
             UpdateFTIndexOp(session)
         if rschema.final or not 'inlined' in entity.edited_attributes:
             return # nothing to do
-        inlined = self.values['inlined']
-        entity = self.entity
+        inlined = entity.inlined
         # check in-lining is necessary / possible
         if not entity.inlined_changed(inlined):
             return # nothing to do
@@ -939,15 +938,14 @@
 
     def __call__(self):
         entity = self.entity
-        rschema = self._cw.vreg.schema.rschema(entity.name)
         newvalues = {}
-        for prop in ('meta', 'symmetric', 'inlined'):
-            if prop in entity:
+        for prop in ('symmetric', 'inlined', 'fulltext_container'):
+            if prop in entity.edited_attributes:
                 newvalues[prop] = entity[prop]
         if newvalues:
+            rschema = self._cw.vreg.schema.rschema(entity.name)
+            SourceDbCWRTypeUpdate(self._cw, rschema=rschema, entity=entity)
             MemSchemaCWRTypeUpdate(self._cw, rschema=rschema, values=newvalues)
-            SourceDbCWRTypeUpdate(self._cw, rschema=rschema, values=newvalues,
-                                  entity=entity)
 
 
 class AfterDelRelationTypeHook(SyncSchemaHook):