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

This commit is contained in:
stroeder
2014-09-25 16:31:00 +00:00
parent 805824b94e
commit 8cc2bc08fd
3 changed files with 25 additions and 7 deletions

View File

@@ -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
@@ -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 $

View File

@@ -93,6 +93,9 @@ class SyncReplConsumer(ReconnectLDAPObject,SyncreplConsumer):
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
@@ -135,8 +138,8 @@ except IndexError,e:
'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...'

View File

@@ -4,7 +4,7 @@ ldap.syncrepl - for implementing syncrepl consumer (see RFC 4533)
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__ = [
@@ -330,6 +330,11 @@ class SyncreplConsumer:
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):
"""
@@ -394,12 +399,12 @@ class SyncreplConsumer:
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'])
@@ -467,3 +472,12 @@ class SyncreplConsumer:
"""
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