hooks/syncschema.py
branchstable
changeset 4827 8a505bf12193
parent 4826 7eba168407c3
child 4828 3e173d598cad
equal deleted inserted replaced
4826:7eba168407c3 4827:8a505bf12193
   224                 (self.newname, self.oldname))
   224                 (self.newname, self.oldname))
   225 
   225 
   226 
   226 
   227 class SourceDbCWRTypeUpdate(hook.Operation):
   227 class SourceDbCWRTypeUpdate(hook.Operation):
   228     """actually update some properties of a relation definition"""
   228     """actually update some properties of a relation definition"""
   229     rschema = values = entity = None # make pylint happy
   229     rschema = entity = None # make pylint happy
   230 
   230 
   231     def precommit_event(self):
   231     def precommit_event(self):
   232         session = self.session
   232         session = self.session
   233         rschema = self.rschema
   233         rschema = self.rschema
   234         entity = self.entity
   234         entity = self.entity
   239                 ftiupdates.add(subjtype)
   239                 ftiupdates.add(subjtype)
   240                 ftiupdates.add(objtype)
   240                 ftiupdates.add(objtype)
   241             UpdateFTIndexOp(session)
   241             UpdateFTIndexOp(session)
   242         if rschema.final or not 'inlined' in entity.edited_attributes:
   242         if rschema.final or not 'inlined' in entity.edited_attributes:
   243             return # nothing to do
   243             return # nothing to do
   244         inlined = self.values['inlined']
   244         inlined = entity.inlined
   245         entity = self.entity
       
   246         # check in-lining is necessary / possible
   245         # check in-lining is necessary / possible
   247         if not entity.inlined_changed(inlined):
   246         if not entity.inlined_changed(inlined):
   248             return # nothing to do
   247             return # nothing to do
   249         # inlined changed, make necessary physical changes!
   248         # inlined changed, make necessary physical changes!
   250         sqlexec = self.session.system_sql
   249         sqlexec = self.session.system_sql
   937     __regid__ = 'syncupdatecwrtype'
   936     __regid__ = 'syncupdatecwrtype'
   938     events = ('after_update_entity',)
   937     events = ('after_update_entity',)
   939 
   938 
   940     def __call__(self):
   939     def __call__(self):
   941         entity = self.entity
   940         entity = self.entity
   942         rschema = self._cw.vreg.schema.rschema(entity.name)
       
   943         newvalues = {}
   941         newvalues = {}
   944         for prop in ('meta', 'symmetric', 'inlined'):
   942         for prop in ('symmetric', 'inlined', 'fulltext_container'):
   945             if prop in entity:
   943             if prop in entity.edited_attributes:
   946                 newvalues[prop] = entity[prop]
   944                 newvalues[prop] = entity[prop]
   947         if newvalues:
   945         if newvalues:
       
   946             rschema = self._cw.vreg.schema.rschema(entity.name)
       
   947             SourceDbCWRTypeUpdate(self._cw, rschema=rschema, entity=entity)
   948             MemSchemaCWRTypeUpdate(self._cw, rschema=rschema, values=newvalues)
   948             MemSchemaCWRTypeUpdate(self._cw, rschema=rschema, values=newvalues)
   949             SourceDbCWRTypeUpdate(self._cw, rschema=rschema, values=newvalues,
       
   950                                   entity=entity)
       
   951 
   949 
   952 
   950 
   953 class AfterDelRelationTypeHook(SyncSchemaHook):
   951 class AfterDelRelationTypeHook(SyncSchemaHook):
   954     """before deleting a CWAttribute or CWRelation entity:
   952     """before deleting a CWAttribute or CWRelation entity:
   955     * if this is a final or inlined relation definition, instantiate an
   953     * if this is a final or inlined relation definition, instantiate an