200 def reset_caches(self): |
200 def reset_caches(self): |
201 """method called during test to reset potential source caches""" |
201 """method called during test to reset potential source caches""" |
202 self._cache = {} |
202 self._cache = {} |
203 self._query_cache = TimedCache(self._cache_ttl) |
203 self._query_cache = TimedCache(self._cache_ttl) |
204 |
204 |
205 def init(self, activated, session=None): |
205 def init(self, activated, source_entity): |
206 """method called by the repository once ready to handle request""" |
206 """method called by the repository once ready to handle request""" |
207 if activated: |
207 if activated: |
208 self.info('ldap init') |
208 self.info('ldap init') |
209 # set minimum period of 5min 1s (the additional second is to |
209 # set minimum period of 5min 1s (the additional second is to |
210 # minimize resonnance effet) |
210 # minimize resonnance effet) |
573 result.append(rec_dict) |
573 result.append(rec_dict) |
574 #print '--->', result |
574 #print '--->', result |
575 self.debug('ldap built results %s', len(result)) |
575 self.debug('ldap built results %s', len(result)) |
576 return result |
576 return result |
577 |
577 |
578 def before_entity_insertion(self, session, lid, etype, eid): |
578 def before_entity_insertion(self, session, lid, etype, eid, sourceparams): |
579 """called by the repository when an eid has been attributed for an |
579 """called by the repository when an eid has been attributed for an |
580 entity stored here but the entity has not been inserted in the system |
580 entity stored here but the entity has not been inserted in the system |
581 table yet. |
581 table yet. |
582 |
582 |
583 This method must return the an Entity instance representation of this |
583 This method must return the an Entity instance representation of this |
584 entity. |
584 entity. |
585 """ |
585 """ |
586 self.debug('ldap before entity insertion') |
586 self.debug('ldap before entity insertion') |
587 entity = super(LDAPUserSource, self).before_entity_insertion(session, lid, etype, eid) |
587 entity = super(LDAPUserSource, self).before_entity_insertion( |
|
588 session, lid, etype, eid, sourceparams) |
588 res = self._search(session, lid, BASE)[0] |
589 res = self._search(session, lid, BASE)[0] |
589 for attr in entity.e_schema.indexable_attributes(): |
590 for attr in entity.e_schema.indexable_attributes(): |
590 entity.cw_edited[attr] = res[self.user_rev_attrs[attr]] |
591 entity.cw_edited[attr] = res[self.user_rev_attrs[attr]] |
591 return entity |
592 return entity |
592 |
593 |
593 def after_entity_insertion(self, session, lid, entity): |
594 def after_entity_insertion(self, session, lid, entity, sourceparams): |
594 """called by the repository after an entity stored here has been |
595 """called by the repository after an entity stored here has been |
595 inserted in the system table. |
596 inserted in the system table. |
596 """ |
597 """ |
597 self.debug('ldap after entity insertion') |
598 self.debug('ldap after entity insertion') |
598 super(LDAPUserSource, self).after_entity_insertion(session, lid, entity) |
599 super(LDAPUserSource, self).after_entity_insertion( |
|
600 session, lid, entity, sourceparams) |
599 dn = lid |
601 dn = lid |
600 for group in self.user_default_groups: |
602 for group in self.user_default_groups: |
601 session.execute('SET X in_group G WHERE X eid %(x)s, G name %(group)s', |
603 session.execute('SET X in_group G WHERE X eid %(x)s, G name %(group)s', |
602 {'x': entity.eid, 'group': group}) |
604 {'x': entity.eid, 'group': group}) |
603 # search for existant email first |
605 # search for existant email first |