Skip to content

Commit

Permalink
New hook syncrepl_refreshdone() in ldap.syncrepl.SyncReplConsumer (th…
Browse files Browse the repository at this point in the history
…anks to Petr Spacek)
  • Loading branch information
stroeder committed Sep 25, 2014
1 parent 805824b commit 8cc2bc0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Released 2.4.17 2014-xx-xx
Changes since 2.4.16:

Lib/
*
* New hook syncrepl_refreshdone() in ldap.syncrepl.SyncReplConsumer
(thanks to Petr Spacek)

Modules/
* Added support for getting file descriptor of connection
Expand Down Expand Up @@ -1122,4 +1123,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.326 2014/09/12 12:02:21 stroeder Exp $
$Id: CHANGES,v 1.327 2014/09/25 16:31:00 stroeder Exp $
7 changes: 5 additions & 2 deletions Demo/pyasn1/syncrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def syncrepl_present(self,uuids,refreshDeletes=False):
for uuid in uuids:
self.__presentUUIDs[uuid] = True

def syncrepl_refreshdone(self):
print 'Initial synchronization is now done, persist phase begins'

def perform_application_sync(self,dn,attributes,previous_attributes):
print 'Performing application sync for:', dn
return True
Expand Down Expand Up @@ -135,8 +138,8 @@ def commenceShutdown(signum, stack):
'X-BINDPW=password\' db.shelve'
sys.exit(1)
except ValueError,e:
print 'Error parsing command-line arguments:',str(e)
sys.exit(1)
print 'Error parsing command-line arguments:',str(e)
sys.exit(1)

while watcher_running:
print 'Connecting to LDAP server now...'
Expand Down
20 changes: 17 additions & 3 deletions Lib/ldap/syncrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See http://www.python-ldap.org/ for project details.
$Id: syncrepl.py,v 1.3 2012/08/09 07:18:31 stroeder Exp $
$Id: syncrepl.py,v 1.4 2014/09/25 16:31:00 stroeder Exp $
"""

#__all__ = [
Expand Down Expand Up @@ -330,6 +330,11 @@ def syncrepl_search(self, base, scope, mode='refreshOnly', cookie=None, **search
self.__refreshDone = False
return self.search_ext(base, scope, **search_args)

def _syncrepl_update_refreshdone(self, newvalue):
callback = newvalue and not self.__refreshDone
self.__refreshDone = newvalue
if callback:
self.syncrepl_refreshdone()

def syncrepl_poll(self, msgid=-1, timeout=None, all=0):
"""
Expand Down Expand Up @@ -394,12 +399,12 @@ def syncrepl_poll(self, msgid=-1, timeout=None, all=0):
self.syncrepl_present(None, refreshDeletes=False)
if 'cookie' in sim.refreshPresent:
self.syncrepl_set_cookie(sim.refreshPresent['cookie'])
self.__refreshDone=sim.refreshPresent['refreshDone']
self._syncrepl_update_refreshdone(sim.refreshPresent['refreshDone'])
elif sim.refreshDelete is not None:
self.syncrepl_present(None, refreshDeletes=True)
if 'cookie' in sim.refreshDelete:
self.syncrepl_set_cookie(sim.refreshDelete['cookie'])
self.__refreshDone=sim.refreshDelete['refreshDone']
self._syncrepl_update_refreshdone(sim.refreshDelete['refreshDone'])
elif sim.syncIdSet is not None:
if sim.syncIdSet['refreshDeletes'] is True:
self.syncrepl_delete(sim.syncIdSet['syncUUIDs'])
Expand Down Expand Up @@ -467,3 +472,12 @@ def syncrepl_entry(self, dn, attrs, uuid):
"""
pass

def syncrepl_refreshdone(self):
"""
Called by syncrepl_poll() between refresh and persist phase.
It indicates that initial synchronization is done and persist phase
follows.
"""
pass

0 comments on commit 8cc2bc0

Please sign in to comment.