hooks/integrity.py
changeset 10662 10942ed172de
parent 9680 8fb8f001f4e2
child 10666 7f6b5f023884
equal deleted inserted replaced
10661:e6eb0c7c2e98 10662:10942ed172de
   245     events = ('before_add_entity', 'before_update_entity')
   245     events = ('before_add_entity', 'before_update_entity')
   246 
   246 
   247     def __call__(self):
   247     def __call__(self):
   248         entity = self.entity
   248         entity = self.entity
   249         eschema = entity.e_schema
   249         eschema = entity.e_schema
   250         for attr, val in entity.cw_edited.iteritems():
   250         for attr, val in entity.cw_edited.items():
   251             if eschema.subjrels[attr].final and eschema.has_unique_values(attr):
   251             if eschema.subjrels[attr].final and eschema.has_unique_values(attr):
   252                 if val is None:
   252                 if val is None:
   253                     continue
   253                     continue
   254                 rql = '%s X WHERE X %s %%(val)s' % (entity.e_schema, attr)
   254                 rql = '%s X WHERE X %s %%(val)s' % (entity.e_schema, attr)
   255                 rset = self._cw.execute(rql, {'val': val})
   255                 rset = self._cw.execute(rql, {'val': val})
   284 
   284 
   285     def __call__(self):
   285     def __call__(self):
   286         entity = self.entity
   286         entity = self.entity
   287         metaattrs = entity.e_schema.meta_attributes()
   287         metaattrs = entity.e_schema.meta_attributes()
   288         edited = entity.cw_edited
   288         edited = entity.cw_edited
   289         for metaattr, (metadata, attr) in metaattrs.iteritems():
   289         for metaattr, (metadata, attr) in metaattrs.items():
   290             if metadata == 'format' and attr in edited:
   290             if metadata == 'format' and attr in edited:
   291                 try:
   291                 try:
   292                     value = edited[attr]
   292                     value = edited[attr]
   293                 except KeyError:
   293                 except KeyError:
   294                     continue # no text to tidy
   294                     continue # no text to tidy