Commit a259a4bd authored by Sebastien Robin's avatar Sebastien Robin

now ERP5SyncML supports external mount point


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1009 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b04b8731
...@@ -99,7 +99,7 @@ class PublicationSynchronization(XMLSyncUtils): ...@@ -99,7 +99,7 @@ class PublicationSynchronization(XMLSyncUtils):
xml += '</SyncML>\n' xml += '</SyncML>\n'
self.sendResponse(from_url=publication.getPublicationUrl(), self.sendResponse(from_url=publication.getPublicationUrl(),
to_url=subscriber.getSubscriptionUrl(),sync_id=publication.id,xml=xml, to_url=subscriber.getSubscriptionUrl(),sync_id=publication.getTitle(),xml=xml,
domain=publication) domain=publication)
return {'has_response':1,'xml':xml} return {'has_response':1,'xml':xml}
......
...@@ -73,7 +73,7 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -73,7 +73,7 @@ class SubscriptionSynchronization(XMLSyncUtils):
xml += '</SyncML>\n' xml += '</SyncML>\n'
self.sendResponse(from_url=subscription.subscription_url, to_url=subscription.publication_url, self.sendResponse(from_url=subscription.subscription_url, to_url=subscription.publication_url,
sync_id=subscription.id, xml=xml,domain=subscription) sync_id=subscription.getTitle(), xml=xml,domain=subscription)
return {'has_response':1,'xml':xml} return {'has_response':1,'xml':xml}
......
...@@ -44,6 +44,7 @@ from xml.dom.minidom import parse, parseString ...@@ -44,6 +44,7 @@ from xml.dom.minidom import parse, parseString
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from PublicationSynchronization import PublicationSynchronization from PublicationSynchronization import PublicationSynchronization
from SubscriptionSynchronization import SubscriptionSynchronization from SubscriptionSynchronization import SubscriptionSynchronization
from Products.CMFCore.utils import getToolByName
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.User import UnrestrictedUser from AccessControl.User import UnrestrictedUser
...@@ -164,10 +165,11 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -164,10 +165,11 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
#if not('publications' in self.objectIds()): #if not('publications' in self.objectIds()):
# publications = Folder('publications') # publications = Folder('publications')
# self._setObject(publications.id, publications) # self._setObject(publications.id, publications)
folder = self.getObjectContainer()
new_id = self.getPublicationIdFromTitle(title) new_id = self.getPublicationIdFromTitle(title)
pub = Publication(new_id, title, publication_url, destination_path, pub = Publication(new_id, title, publication_url, destination_path,
query, xml_mapping, gpg_key) query, xml_mapping, gpg_key)
self._setObject( new_id, pub ) folder._setObject( new_id, pub )
#if len(self.list_publications) == 0: #if len(self.list_publications) == 0:
# self.list_publications = PersistentMapping() # self.list_publications = PersistentMapping()
#self.list_publications[id] = pub #self.list_publications[id] = pub
...@@ -184,10 +186,11 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -184,10 +186,11 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
#if not('subscriptions' in self.objectIds()): #if not('subscriptions' in self.objectIds()):
# subscriptions = Folder('subscriptions') # subscriptions = Folder('subscriptions')
# self._setObject(subscriptions.id, subscriptions) # self._setObject(subscriptions.id, subscriptions)
folder = self.getObjectContainer()
new_id = self.getSubscriptionIdFromTitle(title) new_id = self.getSubscriptionIdFromTitle(title)
sub = Subscription(new_id, title, publication_url, subscription_url, sub = Subscription(new_id, title, publication_url, subscription_url,
destination_path, query, xml_mapping, gpg_key) destination_path, query, xml_mapping, gpg_key)
self._setObject( new_id, sub ) folder._setObject( new_id, sub )
#if len(self.list_subscriptions) == 0: #if len(self.list_subscriptions) == 0:
# self.list_subscriptions = PersistentMapping() # self.list_subscriptions = PersistentMapping()
#self.list_subscriptions[id] = sub #self.list_subscriptions[id] = sub
...@@ -200,8 +203,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -200,8 +203,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
""" """
modify a publication modify a publication
""" """
id = self.getPublicationIdFromTitle(title) pub = self.getPublication(title)
pub = self._getOb(id)
pub.setTitle(title) pub.setTitle(title)
pub.setPublicationUrl(publication_url) pub.setPublicationUrl(publication_url)
pub.setDestinationPath(destination_path) pub.setDestinationPath(destination_path)
...@@ -217,8 +219,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -217,8 +219,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
""" """
modify a subscription modify a subscription
""" """
id = self.getSubscriptionIdFromTitle(title) pub = self.getSubscription(title)
sub = self._getOb(id)
sub.setTitle(title) sub.setTitle(title)
sub.setPublicationUrl(publication_url) sub.setPublicationUrl(publication_url)
sub.setDestinationPath(destination_path) sub.setDestinationPath(destination_path)
...@@ -235,7 +236,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -235,7 +236,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
delete a publication delete a publication
""" """
id = self.getPublicationIdFromTitle(title) id = self.getPublicationIdFromTitle(title)
self._delObject(id) folder = self.getObjectContainer()
folder._delObject(id)
if RESPONSE is not None: if RESPONSE is not None:
RESPONSE.redirect('managePublications') RESPONSE.redirect('managePublications')
...@@ -245,7 +247,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -245,7 +247,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
delete a subscription delete a subscription
""" """
id = self.getSubscriptionIdFromTitle(title) id = self.getSubscriptionIdFromTitle(title)
self._delObject(id) folder = self.getObjectContainer()
folder._delObject(id)
if RESPONSE is not None: if RESPONSE is not None:
RESPONSE.redirect('manageSubscriptions') RESPONSE.redirect('manageSubscriptions')
...@@ -254,8 +257,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -254,8 +257,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
""" """
reset a publication reset a publication
""" """
id = self.getPublicationIdFromTitle(title) pub = self.getPublication(title)
pub = self.getObject(id)
pub.resetAllSubscribers() pub.resetAllSubscribers()
if RESPONSE is not None: if RESPONSE is not None:
RESPONSE.redirect('managePublications') RESPONSE.redirect('managePublications')
...@@ -265,8 +267,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -265,8 +267,7 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
""" """
reset a subscription reset a subscription
""" """
id = self.getSubscriptionIdFromTitle(title) sub = self.getSubscription(title)
sub = self.getObject(id)
sub.resetAllSignatures() sub.resetAllSignatures()
sub.resetAnchors() sub.resetAnchors()
if RESPONSE is not None: if RESPONSE is not None:
...@@ -277,7 +278,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -277,7 +278,8 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
""" """
Return a list of publications Return a list of publications
""" """
object_list = self.objectValues() folder = self.getObjectContainer()
object_list = folder.objectValues()
object_list = filter(lambda x: x.id.find('pub')==0,object_list) object_list = filter(lambda x: x.id.find('pub')==0,object_list)
return object_list return object_list
...@@ -291,12 +293,25 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati ...@@ -291,12 +293,25 @@ class SynchronizationTool( SubscriptionSynchronization, PublicationSynchronizati
return p return p
return None return None
security.declareProtected(Permissions.AccessContentsInformation,'getObjectContainer')
def getObjectContainer(self):
"""
this returns the external mount point if there is one
"""
folder = self
portal_url = getToolByName(self,'portal_url')
root = portal_url.getPortalObject().aq_parent
if 'external_mount_point' in root.objectIds():
folder = root.external_mount_point
return folder
security.declareProtected(Permissions.AccessContentsInformation,'getSubscriptionList') security.declareProtected(Permissions.AccessContentsInformation,'getSubscriptionList')
def getSubscriptionList(self): def getSubscriptionList(self):
""" """
Return a list of publications Return a list of publications
""" """
object_list = self.objectValues() folder = self.getObjectContainer()
object_list = folder.objectValues()
object_list = filter(lambda x: x.id.find('sub')==0,object_list) object_list = filter(lambda x: x.id.find('sub')==0,object_list)
return object_list return object_list
......
...@@ -929,10 +929,10 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -929,10 +929,10 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
has_response = 1 has_response = 1
if domain.domain_type == self.PUB: # We always reply if domain.domain_type == self.PUB: # We always reply
self.sendResponse(from_url=domain.publication_url, to_url=subscriber.subscription_url, self.sendResponse(from_url=domain.publication_url, to_url=subscriber.subscription_url,
sync_id=domain.id, xml=last_xml,domain=domain) sync_id=domain.getTitle(), xml=last_xml,domain=domain)
elif domain.domain_type == self.SUB: elif domain.domain_type == self.SUB:
self.sendResponse(from_url=domain.subscription_url, to_url=domain.publication_url, self.sendResponse(from_url=domain.subscription_url, to_url=domain.publication_url,
sync_id=domain.id, xml=last_xml,domain=domain) sync_id=domain.getTitle(), xml=last_xml,domain=domain)
return {'has_response':has_response,'xml':last_xml} return {'has_response':has_response,'xml':last_xml}
subscriber.setLastSentMessage('') subscriber.setLastSentMessage('')
...@@ -1012,7 +1012,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1012,7 +1012,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
if domain.domain_type == self.PUB: # We always reply if domain.domain_type == self.PUB: # We always reply
subscriber.setLastSentMessage(xml) subscriber.setLastSentMessage(xml)
self.sendResponse(from_url=domain.publication_url, to_url=subscriber.subscription_url, self.sendResponse(from_url=domain.publication_url, to_url=subscriber.subscription_url,
sync_id=domain.id, xml=xml,domain=domain) sync_id=domain.getTitle(), xml=xml,domain=domain)
has_response = 1 has_response = 1
elif domain.domain_type == self.SUB: elif domain.domain_type == self.SUB:
if self.checkAlert(remote_xml) or \ if self.checkAlert(remote_xml) or \
...@@ -1020,6 +1020,6 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1020,6 +1020,6 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
has_status_list: has_status_list:
subscriber.setLastSentMessage(xml) subscriber.setLastSentMessage(xml)
self.sendResponse(from_url=domain.subscription_url, to_url=domain.publication_url, self.sendResponse(from_url=domain.subscription_url, to_url=domain.publication_url,
sync_id=domain.id, xml=xml,domain=domain) sync_id=domain.getTitle(), xml=xml,domain=domain)
has_response = 1 has_response = 1
return {'has_response':has_response,'xml':xml} return {'has_response':has_response,'xml':xml}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment