hooks/metadata.py
changeset 8387 b59af20a868d
parent 8190 2a3c1b787688
child 8544 3d049071957e
equal deleted inserted replaced
8386:249b21722e5e 8387:b59af20a868d
   197             syssource = newsource.repo_source
   197             syssource = newsource.repo_source
   198             oldsource = self._cw.entity_from_eid(schange[self.eidfrom])
   198             oldsource = self._cw.entity_from_eid(schange[self.eidfrom])
   199             entity = self._cw.entity_from_eid(self.eidfrom)
   199             entity = self._cw.entity_from_eid(self.eidfrom)
   200             # copy entity if necessary
   200             # copy entity if necessary
   201             if not oldsource.repo_source.copy_based_source:
   201             if not oldsource.repo_source.copy_based_source:
   202                 entity.complete(skip_bytes=False)
   202                 entity.complete(skip_bytes=False, skip_pwd=False)
   203                 if not entity.creation_date:
   203                 if not entity.creation_date:
   204                     entity.cw_attr_cache['creation_date'] = datetime.now()
   204                     entity.cw_attr_cache['creation_date'] = datetime.now()
   205                 if not entity.modification_date:
   205                 if not entity.modification_date:
   206                     entity.cw_attr_cache['modification_date'] = datetime.now()
   206                     entity.cw_attr_cache['modification_date'] = datetime.now()
   207                 entity.cw_attr_cache['cwuri'] = u'%s%s' % (self._cw.base_url(), entity.eid)
   207                 entity.cw_attr_cache['cwuri'] = u'%s%s' % (self._cw.base_url(), entity.eid)
   208                 for rschema, attrschema in entity.e_schema.attribute_definitions():
       
   209                     if attrschema == 'Password' and \
       
   210                        rschema.rdef(entity.e_schema, attrschema).cardinality[0] == '1':
       
   211                         from logilab.common.shellutils import generate_password
       
   212                         entity.cw_attr_cache[rschema.type] = generate_password()
       
   213                 entity.cw_edited = EditedEntity(entity, **entity.cw_attr_cache)
   208                 entity.cw_edited = EditedEntity(entity, **entity.cw_attr_cache)
   214                 syssource.add_entity(self._cw, entity)
   209                 syssource.add_entity(self._cw, entity)
   215             # we don't want the moved entity to be reimported later.  To
   210             # we don't want the moved entity to be reimported later.  To
   216             # distinguish this state, the trick is to change the associated
   211             # distinguish this state, the trick is to change the associated
   217             # record in the 'entities' system table with eid=-eid while leaving
   212             # record in the 'entities' system table with eid=-eid while leaving