From e3f4af0f5c74febadf8d8252a6273e99bd2fcdd9 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Fri, 22 Oct 2004 08:53:02 +0000 Subject: [PATCH] we can set id_generator and gid_generator into the user interface git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1866 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5SyncML/Subscription.py | 6 ++++-- product/ERP5SyncML/SynchronizationTool.py | 10 ++++++++-- product/ERP5SyncML/XMLSyncUtils.py | 2 +- .../ERP5SyncML/dtml/managePublications.dtml | 20 +++++++++++++++++++ .../ERP5SyncML/dtml/manageSubscriptions.dtml | 20 +++++++++++++++++++ 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/product/ERP5SyncML/Subscription.py b/product/ERP5SyncML/Subscription.py index d5c07ae9aa0..4ab5c777be9 100755 --- a/product/ERP5SyncML/Subscription.py +++ b/product/ERP5SyncML/Subscription.py @@ -833,7 +833,7 @@ class Subscription(Folder, SyncCode): This set the method name wich allows to find a gid from any object """ - if method in (None,''): + if method in (None,'','None'): method = 'getId' self.gid_generator = method @@ -927,7 +927,7 @@ class Subscription(Folder, SyncCode): o_base = aq_base(object) new_id = None if callable(id_generator): - new_id = id_generator(object) + new_id = id_generator(object,gid=gid) elif hasattr(o_base, id_generator): generator = getattr(object, id_generator) new_id = generator() @@ -940,6 +940,8 @@ class Subscription(Folder, SyncCode): This set the method name wich allows to generate a new id """ + if method in ('','None'): + method = None self.id_generator = method def getIdGenerator(self): diff --git a/product/ERP5SyncML/SynchronizationTool.py b/product/ERP5SyncML/SynchronizationTool.py index faff7c09012..0db1c0cecb2 100755 --- a/product/ERP5SyncML/SynchronizationTool.py +++ b/product/ERP5SyncML/SynchronizationTool.py @@ -202,7 +202,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati security.declareProtected(Permissions.ModifyPortalContent, 'manage_editPublication') def manage_editPublication(self, title, publication_url, destination_path, - query, xml_mapping, conduit, gpg_key, RESPONSE=None): + query, xml_mapping, conduit, gpg_key, id_generator, + gid_generator, RESPONSE=None): """ modify a publication """ @@ -214,12 +215,15 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati pub.setConduit(conduit) pub.setXMLMapping(xml_mapping) pub.setGPGKey(gpg_key) + pub.setIdGenerator(id_generator) + pub.setGidGenerator(gid_generator) if RESPONSE is not None: RESPONSE.redirect('managePublications') security.declareProtected(Permissions.ModifyPortalContent, 'manage_editSubscription') def manage_editSubscription(self, title, publication_url, subscription_url, - destination_path, query, xml_mapping, conduit, gpg_key, RESPONSE=None): + destination_path, query, xml_mapping, conduit, gpg_key, id_generator, + gid_generator, RESPONSE=None): """ modify a subscription """ @@ -232,6 +236,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati sub.setXMLMapping(xml_mapping) sub.setGPGKey(gpg_key) sub.setSubscriptionUrl(subscription_url) + sub.setIdGenerator(id_generator) + sub.setGidGenerator(gid_generator) if RESPONSE is not None: RESPONSE.redirect('manageSubscriptions') diff --git a/product/ERP5SyncML/XMLSyncUtils.py b/product/ERP5SyncML/XMLSyncUtils.py index 13e652ed93b..40e291d051d 100755 --- a/product/ERP5SyncML/XMLSyncUtils.py +++ b/product/ERP5SyncML/XMLSyncUtils.py @@ -769,7 +769,7 @@ class XMLSyncUtilsMixin(SyncCode): if next_action.nodeName == 'Add': # Then store the xml of this new subobject if object is None: - object_id = domain.generateNewIdWithGenerator(object=destination_path) + object_id = domain.generateNewIdWithGenerator(object=destination_path,gid=object_gid) conflict_list += conduit.addNode(xml=data_subnode, object=destination_path, object_id=object_id) object = domain.getObjectFromGid(object_gid) diff --git a/product/ERP5SyncML/dtml/managePublications.dtml b/product/ERP5SyncML/dtml/managePublications.dtml index f54746cd612..993d1b714e6 100755 --- a/product/ERP5SyncML/dtml/managePublications.dtml +++ b/product/ERP5SyncML/dtml/managePublications.dtml @@ -107,6 +107,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <input type="text" name="gpg_key" value="<dtml-var getGPGKey>" size="40" /> </td> </tr> + <tr> + <td align="left" valign="top"> + <div class="form-label"> + Id Generator + </label></div> + </td> + <td align="left" valign="top"> + <input type="text" name="id_generator" value="<dtml-var getIdGenerator>" size="40" /> + </td> + </tr> + <tr> + <td align="left" valign="top"> + <div class="form-label"> + Gid Generator + </label></div> + </td> + <td align="left" valign="top"> + <input type="text" name="gid_generator" value="<dtml-var getGidGenerator>" size="40" /> + </td> + </tr> </table> <table> <tr> diff --git a/product/ERP5SyncML/dtml/manageSubscriptions.dtml b/product/ERP5SyncML/dtml/manageSubscriptions.dtml index 0b2170f1345..7adabdcfe54 100755 --- a/product/ERP5SyncML/dtml/manageSubscriptions.dtml +++ b/product/ERP5SyncML/dtml/manageSubscriptions.dtml @@ -117,6 +117,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. <input type="text" name="gpg_key" value="<dtml-var getGPGKey>" size="40" /> </td> </tr> + <tr> + <td align="left" valign="top"> + <div class="form-label"> + Id Generator + </label></div> + </td> + <td align="left" valign="top"> + <input type="text" name="id_generator" value="<dtml-var getIdGenerator>" size="40" /> + </td> + </tr> + <tr> + <td align="left" valign="top"> + <div class="form-label"> + Gid Generator + </label></div> + </td> + <td align="left" valign="top"> + <input type="text" name="gid_generator" value="<dtml-var getGidGenerator>" size="40" /> + </td> + </tr> </table> <table> <tr> -- 2.30.9