From 94094bee2f59eddeef7622ee7f20ab9a3f9c6968 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Wed, 21 Jan 2004 10:20:45 +0000 Subject: [PATCH] many updates on method names, ex: RemoteValue -> SubscriberValue LocalValue -> PublisherValue edit_Publications -> manage_editPublication Added several methods: applySubscriberDocument applyPublisherDocument resolveContext git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@228 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5SyncML/Conduit/ERP5Conduit.py | 6 +- product/ERP5SyncML/Subscription.py | 75 +++++++----- product/ERP5SyncML/SynchronizationTool.py | 115 +++++++++++++----- product/ERP5SyncML/dtml/addPublications.dtml | 2 +- product/ERP5SyncML/dtml/addSubscriptions.dtml | 2 +- product/ERP5SyncML/dtml/manageConflicts.dtml | 14 +-- .../ERP5SyncML/dtml/managePublications.dtml | 8 +- .../ERP5SyncML/dtml/manageSubscriptions.dtml | 8 +- 8 files changed, 143 insertions(+), 87 deletions(-) diff --git a/product/ERP5SyncML/Conduit/ERP5Conduit.py b/product/ERP5SyncML/Conduit/ERP5Conduit.py index 8bea0c8292..3c8ffbec81 100755 --- a/product/ERP5SyncML/Conduit/ERP5Conduit.py +++ b/product/ERP5SyncML/Conduit/ERP5Conduit.py @@ -115,7 +115,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): This fucntion returns conflict_list, wich is of the form, [conflict1,conflict2,...] where conclict1 is of the form : - [object.getPath(),keyword,local_and_actual_value,remote_value] + [object.getPath(),keyword,local_and_actual_value,subscriber_value] """ conflict_list = [] xml = self.convertToXml(xml) @@ -351,8 +351,8 @@ class ERP5Conduit(XMLSyncUtilsMixin): #conflict_list += [Conflict(object_path=object.getPhysicalPath(), # keyword=keyword, # xupdate=string_io)] - #local_value=current_data, # not needed any more - #remote_value=data)] # not needed any more + #publisher_value=current_data, # not needed any more + #subscriber_value=data)] # not needed any more # We will now apply the argument with the method edit if args != {} and (isConflict==0 or force): LOG('updateNode',0,'object._edit, args: %s' % str(args)) diff --git a/product/ERP5SyncML/Subscription.py b/product/ERP5SyncML/Subscription.py index d878992d8a..67b46ea812 100755 --- a/product/ERP5SyncML/Subscription.py +++ b/product/ERP5SyncML/Subscription.py @@ -39,19 +39,18 @@ class Conflict(SyncCode, Implicit): """ object_path : the path of the obect keyword : an identifier of the conflict - local_value : the value that we have locally - remote_value : the value sent by the remote box + publisher_value : the value that we have locally + subscriber_value : the value sent by the remote box """ - def __init__(self, object_path=None, keyword=None, xupdate=None, local_value=None,\ - remote_value=None, domain=None, domain_id=None): + def __init__(self, object_path=None, keyword=None, xupdate=None, publisher_value=None,\ + subscriber_value=None, subscriber=None): self.object_path=object_path self.keyword = keyword - self.setLocalValue(local_value) - self.setRemoteValue(remote_value) - self.domain = domain + self.setLocalValue(publisher_value) + self.setRemoteValue(subscriber_value) + self.subscriber = subscriber self.resetXupdate() - self.domain_id = domain_id def getObjectPath(self): """ @@ -59,11 +58,11 @@ class Conflict(SyncCode, Implicit): """ return self.object_path - def getLocalValue(self): + def getPublisherValue(self): """ get the domain """ - return self.local_value + return self.publisher_value def getXupdateList(self): """ @@ -101,51 +100,67 @@ class Conflict(SyncCode, Implicit): get the domain """ try: - self.local_value = value + self.publisher_value = value except TypeError: # It happens when we try to store StringIO - self.local_value = None + self.publisher_value = None - def getRemoteValue(self): + def getSubscriberValue(self): """ get the domain """ - return self.remote_value + return self.subscriber_value def setRemoteValue(self, value): """ get the domain """ try: - self.remote_value = value + self.subscriber_value = value except TypeError: # It happens when we try to store StringIO - self.remote_value = None + self.subscriber_value = None - def applyLocalValue(self): + def applyPublisherValue(self): """ after a conflict resolution, we have decided to keep the local version of this object """ p_sync = getToolByName(self,'portal_synchronizations') - p_sync.applyLocalValue(self) + p_sync.applyPublisherValue(self) - def applyRemoteValue(self): + def applyPublisherDocument(self): + """ + after a conflict resolution, we have decided + to keep the local version of this object + """ + p_sync = getToolByName(self,'portal_synchronizations') + p_sync.applyPublisherDocument(self) + + def applySubscriberDocument(self): + """ + after a conflict resolution, we have decided + to keep the local version of this object + """ + p_sync = getToolByName(self,'portal_synchronizations') + p_sync.applySubscriberDocument(self) + + def applySubscriberValue(self): """ get the domain """ p_sync = getToolByName(self,'portal_synchronizations') - p_sync.applyRemoteValue(self) + p_sync.applySubscriberValue(self) - def setDomain(self, domain): + def setSubscriber(self, subscriber): """ set the domain """ - self.domain = domain + self.subscriber = subscriber - def getDomain(self): + def getSubscriber(self): """ get the domain """ - return self.domain + return self.subscriber def getKeyword(self): """ @@ -153,17 +168,11 @@ class Conflict(SyncCode, Implicit): """ return self.keyword - def getDomainId(self): - """ - get the domain id - """ - return self.domain_id - - def setDomainId(self, domain_id): + def getPropertyId(self): """ - set the domain + get the property id """ - self.domain_id = domain_id + return self.keyword class Signature(SyncCode): """ diff --git a/product/ERP5SyncML/SynchronizationTool.py b/product/ERP5SyncML/SynchronizationTool.py index 1229fabba0..6f1ab5859f 100755 --- a/product/ERP5SyncML/SynchronizationTool.py +++ b/product/ERP5SyncML/SynchronizationTool.py @@ -107,8 +107,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, managePublications = DTMLFile( 'dtml/managePublications', globals() ) security.declareProtected( CMFCorePermissions.ManagePortal - , 'addPublicationsForm' ) - addPublicationsForm = DTMLFile( 'dtml/addPublications', globals() ) + , 'manage_addPublicationForm' ) + manage_addPublicationForm = DTMLFile( 'dtml/manage_addPublication', globals() ) security.declareProtected( CMFCorePermissions.ManagePortal , 'manageSubsciptions' ) @@ -119,8 +119,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, manageConflicts = DTMLFile( 'dtml/manageConflicts', globals() ) security.declareProtected( CMFCorePermissions.ManagePortal - , 'addSubscriptionsForm' ) - addSubscriptionsForm = DTMLFile( 'dtml/addSubscriptions', globals() ) + , 'manage_addSubscriptionForm' ) + manage_addSubscriptionForm = DTMLFile( 'dtml/manage_addSubscription', globals() ) security.declareProtected( CMFCorePermissions.ManagePortal , 'editProperties' ) @@ -141,8 +141,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, + '?manage_tabs_message=Tool+updated.' ) - security.declareProtected(Permissions.ModifyPortalContent, 'addPublications') - def addPublications(self, id, publication_url, destination_path, + security.declareProtected(Permissions.ModifyPortalContent, 'manage_addPublication') + def manage_addPublication(self, id, publication_url, destination_path, query, xml_mapping, RESPONSE=None): """ create a new publication @@ -155,8 +155,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('managePublications') - security.declareProtected(Permissions.ModifyPortalContent, 'addSubscriptions') - def addSubscriptions(self, id, publication_url, subscription_url, + security.declareProtected(Permissions.ModifyPortalContent, 'manage_addSubscription') + def manage_addSubscription(self, id, publication_url, subscription_url, destination_path, query, xml_mapping, RESPONSE=None): """ XXX should be renamed as addSubscription @@ -170,8 +170,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('manageSubscriptions') - security.declareProtected(Permissions.ModifyPortalContent, 'editPublications') - def editPublications(self, id, publication_url, destination_path, + security.declareProtected(Permissions.ModifyPortalContent, 'manage_editPublication') + def manage_editPublication(self, id, publication_url, destination_path, query, xml_mapping, RESPONSE=None): """ modify a publication @@ -182,8 +182,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('managePublications') - security.declareProtected(Permissions.ModifyPortalContent, 'editSubscriptions') - def editSubscriptions(self, id, publication_url, subscription_url, + security.declareProtected(Permissions.ModifyPortalContent, 'manage_editSubscription') + def manage_editSubscription(self, id, publication_url, subscription_url, destination_path, query, xml_mapping, RESPONSE=None): """ modify a subscription @@ -194,8 +194,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('manageSubscriptions') - security.declareProtected(Permissions.ModifyPortalContent, 'deletePublications') - def deletePublications(self, id, RESPONSE=None): + security.declareProtected(Permissions.ModifyPortalContent, 'manage_deletePublication') + def manage_deletePublication(self, id, RESPONSE=None): """ delete a publication """ @@ -203,8 +203,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('managePublications') - security.declareProtected(Permissions.ModifyPortalContent, 'deleteSubscriptions') - def deleteSubscriptions(self, id, RESPONSE=None): + security.declareProtected(Permissions.ModifyPortalContent, 'manage_deleteSubscription') + def manage_deleteSubscription(self, id, RESPONSE=None): """ delete a subscription """ @@ -212,8 +212,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('manageSubscriptions') - security.declareProtected(Permissions.ModifyPortalContent, 'ResetPublications') - def ResetPublications(self, id, RESPONSE=None): + security.declareProtected(Permissions.ModifyPortalContent, 'manage_resetPublication') + def manage_resetPublication(self, id, RESPONSE=None): """ reset a publication """ @@ -221,8 +221,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, if RESPONSE is not None: RESPONSE.redirect('managePublications') - security.declareProtected(Permissions.ModifyPortalContent, 'ResetSubscriptions') - def ResetSubscriptions(self, id, RESPONSE=None): + security.declareProtected(Permissions.ModifyPortalContent, 'manage_resetSubscription') + def manage_resetSubscription(self, id, RESPONSE=None): """ reset a subscription XXX R -> r @@ -258,8 +258,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, return_list += [self.list_subscriptions[key]] return return_list - security.declareProtected(Permissions.AccessContentsInformation,'getDomainList') - def getDomainList(self): + security.declareProtected(Permissions.AccessContentsInformation,'') + def getSynchronizationList(self): """ Returns the list of subscriptions and publications getSynchronizationList ? (mon choix) @@ -269,13 +269,14 @@ class SynchronizationTool( UniqueObject, SimpleItem, return self.getSubscriptionList() + self.getPublicationList() security.declareProtected(Permissions.AccessContentsInformation,'getConflictList') - def getConflictList(self, path=None): + def getConflictList(self, context=None): """ Retrieve the list of all conflicts Here the list is as follow : [conflict_1,conflict2,...] where conflict_1 is like: - ['publication',publication_id,object.getPath(),keyword,local_value,remote_value] + ['publication',publication_id,object.getPath(),keyword,publisher_value,subscriber_value] """ + path = self.resolveContext(context) conflict_list = [] for publication in self.getPublicationList(): for subscriber in publication.getSubscriberList(): @@ -300,8 +301,17 @@ class SynchronizationTool( UniqueObject, SimpleItem, return new_list return conflict_list + security.declareProtected(Permissions.AccessContentsInformation,'getDocumentConflictList') + def getDocumentConflictList(self, context=None): + """ + Retrieve the list of all conflicts for a given document + Well, this is the same thing as getConflictList with a path + """ + return self.getConflictList(context) + + security.declareProtected(Permissions.AccessContentsInformation,'getSynchronizationState') - def getSynchronizationState(self, path): + def getSynchronizationState(self, context): """ context : the context on which we are looking for state @@ -316,6 +326,7 @@ class SynchronizationTool( UniqueObject, SimpleItem, type -> '/titi/toto' or ('','titi', 'toto') or <Base instance 1562567> object = self.resolveContext(context) (method to add) """ + path = self.resolveContext(context) conflict_list = self.getConflictList() state_list= [] LOG('getSynchronizationState',0,'path: %s' % str(path)) @@ -323,7 +334,7 @@ class SynchronizationTool( UniqueObject, SimpleItem, if conflict.getObjectPath() == path: LOG('getSynchronizationState',0,'found a conflict: %s' % str(conflict)) state_list += [[conflict.getDomain(),self.CONFLICT]] - for domain in self.getDomainList(): + for domain in self.getSynchronizationList(): destination = domain.getDestinationPath() LOG('getSynchronizationState',0,'destination: %s' % str(destination)) j_path = '/'.join(path) @@ -349,8 +360,8 @@ class SynchronizationTool( UniqueObject, SimpleItem, state_list += [[subscriber,state]] return state_list - security.declareProtected(Permissions.ModifyPortalContent, 'applyLocalValue') - def applyLocalValue(self, conflict): + security.declareProtected(Permissions.ModifyPortalContent, 'applyPublisherValue') + def applyPublisherValue(self, conflict): """ after a conflict resolution, we have decided to keep the local version of an object @@ -372,8 +383,28 @@ class SynchronizationTool( UniqueObject, SimpleItem, if signature.getConflictList() == []: signature.setStatus(self.PUB_CONFLICT_MERGE) - security.declareProtected(Permissions.ModifyPortalContent, 'applyRemoteValue') - def applyRemoteValue(self, conflict): + security.declareProtected(Permissions.ModifyPortalContent, 'applyPublisherDocument') + def applyPublisherDocument(self, conflict): + """ + apply the publisher value for all conflict of the given document + """ + subscriber = conflict.getSubscriber() + for c in self.getConflictList(conflict.getObjectPath()): + if c.getSubscriber() == subscriber: + c.applyPublisherValue() + + security.declareProtected(Permissions.ModifyPortalContent, 'applySubscriberDocument') + def applySubscriberDocument(self, conflict): + """ + apply the subscriber value for all conflict of the given document + """ + subscriber = conflict.getSubscriber() + for c in self.getConflictList(conflict.getObjectPath()): + if c.getSubscriber() == subscriber: + c.applySubscriberValue() + + security.declareProtected(Permissions.ModifyPortalContent, 'applySubscriberValue') + def applySubscriberValue(self, conflict): """ after a conflict resolution, we have decided to keep the local version of an object @@ -398,7 +429,7 @@ class SynchronizationTool( UniqueObject, SimpleItem, the remote server Suggestion: - manage_applyLocalValue XXX + manage_applyPublisherValue XXX Suggestion: add global apply (not conflict per conflict) XXX @@ -418,7 +449,7 @@ class SynchronizationTool( UniqueObject, SimpleItem, LOG('manageLocalValue',0,'found the keyword') if '/'.join(conflict.getObjectPath())==object_path: if conflict.getDomain().getSubscriptionUrl()==subscription_url: - conflict.applyLocalValue() + conflict.applyPublisherValue() if RESPONSE is not None: RESPONSE.redirect('manageConflicts') @@ -437,8 +468,26 @@ class SynchronizationTool( UniqueObject, SimpleItem, LOG('manageLocalValue',0,'found the keyword') if '/'.join(conflict.getObjectPath())==object_path: if conflict.getDomain().getSubscriptionUrl()==subscription_url: - conflict.applyRemoteValue() + conflict.applySubscriberValue() if RESPONSE is not None: RESPONSE.redirect('manageConflicts') + def resolveContext(self, context): + """ + We try to return a path (like ('','erp5','foo') from the context. + Context can be : + - a path + - an object + - a string representing a path + """ + if context is None: + return context + elif type(context) is type(()): + return context + elif type(context) is type('a'): + return tuple(context.split('/')) + else: + return context.getPhysicalPath() + + InitializeClass( SynchronizationTool ) diff --git a/product/ERP5SyncML/dtml/addPublications.dtml b/product/ERP5SyncML/dtml/addPublications.dtml index c9396681f1..6b2ef4b6aa 100755 --- a/product/ERP5SyncML/dtml/addPublications.dtml +++ b/product/ERP5SyncML/dtml/addPublications.dtml @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <dtml-var manage_form_title> </dtml-let> -<form action="addPublications" method="POST"> +<form action="manage_addPublication" method="POST"> <table cellspacing="0" cellpadding="2" border="0"> <tr> <td align="left" valign="top"> diff --git a/product/ERP5SyncML/dtml/addSubscriptions.dtml b/product/ERP5SyncML/dtml/addSubscriptions.dtml index c4fde74d9c..aaea0442f1 100755 --- a/product/ERP5SyncML/dtml/addSubscriptions.dtml +++ b/product/ERP5SyncML/dtml/addSubscriptions.dtml @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <dtml-var manage_form_title> </dtml-let> -<form action="addSubscriptions" method="POST"> +<form action="manage_addSubscription" method="POST"> <table cellspacing="0" cellpadding="2" border="0"> <tr> <td align="left" valign="top"> diff --git a/product/ERP5SyncML/dtml/manageConflicts.dtml b/product/ERP5SyncML/dtml/manageConflicts.dtml index ec7ad2d8fc..c84a8f4e9b 100755 --- a/product/ERP5SyncML/dtml/manageConflicts.dtml +++ b/product/ERP5SyncML/dtml/manageConflicts.dtml @@ -34,21 +34,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <tr> <th align="left" valign="top"></th> <th align="left" valign="top">Side</th> - <th align="left" valign="top">Id</th> <th align="left" valign="top">Object path</th> - <th align="left" valign="top">keyword</th> + <th align="left" valign="top">Property Id</th> <th align="left" valign="top">Local Value</th> <th align="left" valign="top">Remote Value</th> </tr> <dtml-in prefix="loop" expr="getConflictList()"> <tr> - <td align="left" valign="top"><a href="manageLocalValue?subscription_url=<dtml-var expr="loop_item.getDomain().getSubscriptionUrl()">&keyword=<dtml-var keyword>&object_path=<dtml-var "'/'.join(object_path)">">Local</a> <a href="manageRemoteValue?subscription_url=<dtml-var expr="loop_item.getDomain().getSubscriptionUrl()">&keyword=<dtml-var keyword>&object_path=<dtml-var "'/'.join(object_path)">">Remote</a></td> - <td align="left" valign="top"><dtml-var expr="loop_item.getDomain().getSubscriptionUrl()"></td> - <td align="left" valign="top"><dtml-var domain></td> + <td align="left" valign="top"><a href="manageLocalValue?subscription_url=<dtml-var expr="loop_item.getSubscriber().getSubscriptionUrl()">&property_id=<dtml-var expr="loop_item.getPropertyId()">&object_path=<dtml-var "'/'.join(object_path)">">Publisher</a> <a href="manageRemoteValue?subscription_url=<dtml-var expr="loop_item.getSubscriber().getSubscriptionUrl()">&property_id=<dtml-var expr="loop_item.getPropertyId()">&object_path=<dtml-var "'/'.join(object_path)">">Subscriber</a></td> + <td align="left" valign="top"><dtml-var expr="loop_item.getSubscriber().getSubscriptionUrl()"></td> <td align="left" valign="top"><dtml-var "'/'.join(object_path)"></td> - <td align="left" valign="top"><dtml-var keyword></td> - <td align="left" valign="top"><dtml-var local_value></td> - <td align="left" valign="top"><dtml-var remote_value></td> + <td align="left" valign="top"><dtml-var expr="loop_item.getPropertyId()"></td> + <td align="left" valign="top"><dtml-var expr="loop_item.getPublisherValue()"></td> + <td align="left" valign="top"><dtml-var expr="loop_item.getSubscriberValue()"></td> </tr> </dtml-in> </table> diff --git a/product/ERP5SyncML/dtml/managePublications.dtml b/product/ERP5SyncML/dtml/managePublications.dtml index 50d2dbd011..ebac9aec08 100755 --- a/product/ERP5SyncML/dtml/managePublications.dtml +++ b/product/ERP5SyncML/dtml/managePublications.dtml @@ -29,13 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <dtml-var manage_page_header> <dtml-var manage_tabs> -<form action="addPublicationsForm"> +<form action="manage_addPublicationForm"> <input type="submit" name="addPublication:method" value="Add a publication"> </form> <dtml-in getPublicationList> <h3>Publication <dtml-var sequence-index></br></h3> - <form action="editPublications" method="POST"> + <form action="manage_editPublication" method="POST"> <table cellspacing="0" cellpadding="2" border="0"> <tr> <td align="left" valign="top"> @@ -100,12 +100,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <input type="hidden" name="id" value="<dtml-var getId>" > <!--input type="hidden" name="subscription" value="<dtml-var getSubscriptionList>" --> </form> - <form action="ResetPublications" method="POST"> + <form action="manage_resetPublication" method="POST"> <td align="left" valign="top"> <input type="submit" value=" Reset "> <input type="hidden" name="id" value="<dtml-var getId>" > </form> - <form action="deletePublications" method="POST"> + <form action="manage_deletePublication" method="POST"> <td align="left" valign="top"> <input type="submit" value=" Delete "> <input type="hidden" name="id" value="<dtml-var getId>" > diff --git a/product/ERP5SyncML/dtml/manageSubscriptions.dtml b/product/ERP5SyncML/dtml/manageSubscriptions.dtml index fb27659098..07c8e64c9b 100755 --- a/product/ERP5SyncML/dtml/manageSubscriptions.dtml +++ b/product/ERP5SyncML/dtml/manageSubscriptions.dtml @@ -29,13 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <dtml-var manage_page_header> <dtml-var manage_tabs> -<form action="addSubscriptionsForm"> +<form action="manage_addSubscriptionForm"> <input type="submit" name="addSubscription:method" value="Add a Subscription"> </form> <dtml-in getSubscriptionList> <h3>Subscription <dtml-var sequence-index></br></h3> - <form action="editSubscriptions" method="POST"> + <form action="manage_editSubscription" method="POST"> <table cellspacing="0" cellpadding="2" border="0"> <tr> <td align="left" valign="top"> @@ -114,12 +114,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <input type="submit" value=" LastSync "> <input type="hidden" name="id" value="<dtml-var getId>" > </form> - <form action="ResetSubscriptions" method="POST"> + <form action="manage_resetSubscription" method="POST"> <td align="left" valign="top"> <input type="submit" value=" Reset "> <input type="hidden" name="id" value="<dtml-var getId>" > </form> - <form action="deleteSubscriptions" method="POST"> + <form action="manage_deleteSubscription" method="POST"> <td align="left" valign="top"> <input type="submit" value=" Delete "> <input type="hidden" name="id" value="<dtml-var getId>" > -- 2.30.9