[ldapfeed] simplify deactivation of unencountered users
there is no need for the by_etype intermediary dictionnary since we only
consider CWUsers.
--- a/sobjects/ldapparser.py Tue Nov 24 10:04:18 2015 +0100
+++ b/sobjects/ldapparser.py Mon Nov 23 14:26:44 2015 +0100
@@ -1,4 +1,4 @@
-# copyright 2011-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2011-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -100,18 +100,12 @@
super(DataFeedLDAPAdapter, self).handle_deletion(config, cnx, myuris)
return
if myuris:
- byetype = {}
for extid, (eid, etype) in myuris.items():
- if self.is_deleted(extid, etype, eid):
- byetype.setdefault(etype, []).append(str(eid))
-
- for etype, eids in byetype.items():
- if etype != 'CWUser':
+ if etype != 'CWUser' or not self.is_deleted(extid, etype, eid):
continue
- self.info('deactivate %s %s entities', len(eids), etype)
- for eid in eids:
- wf = cnx.entity_from_eid(eid).cw_adapt_to('IWorkflowable')
- wf.fire_transition_if_possible('deactivate')
+ self.info('deactivate user %s', eid)
+ wf = cnx.entity_from_eid(eid).cw_adapt_to('IWorkflowable')
+ wf.fire_transition_if_possible('deactivate')
cnx.commit()
def update_if_necessary(self, entity, attrs):