Commit c6b366b2 authored by Sebastien Robin's avatar Sebastien Robin

- add vcard and mobile phone support

- clean some parts


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15529 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3a40f0f5
...@@ -84,16 +84,6 @@ class Subscriber(Subscription): ...@@ -84,16 +84,6 @@ class Subscriber(Subscription):
Send ACK for a group of documents Send ACK for a group of documents
""" """
def getConduit(self):
"""
Return the conduit of the publication
"""
#LOG('Subscriber.getConduit, self.getPhysicalPath()',0,self.getPhysicalPath())
#LOG('Subscriber.getConduit, self.getParent().getPhysicalPath()',0,self.aq_parent.getPhysicalPath())
#LOG('Subscriber.getConduit, self.getParent()',0,self.getParent())
return self.aq_parent.getConduit()
#return self.conduit
def SendDocuments(self): def SendDocuments(self):
""" """
We send all the updated documents (ie. documents not marked We send all the updated documents (ie. documents not marked
...@@ -155,7 +145,8 @@ class Publication(Subscription): ...@@ -155,7 +145,8 @@ class Publication(Subscription):
def __init__(self, id, title, publication_url, destination_path, def __init__(self, id, title, publication_url, destination_path,
source_uri, query, xml_mapping, conduit, gpg_key, id_generator, source_uri, query, xml_mapping, conduit, gpg_key, id_generator,
gid_generator, media_type, auth_required, authentication_format, gid_generator, media_type, auth_required, authentication_format,
authentication_type, activity_enabled): authentication_type, activity_enabled, synchronize_with_erp5_sites,
sync_content_type):
""" """
constructor constructor
""" """
...@@ -178,6 +169,8 @@ class Publication(Subscription): ...@@ -178,6 +169,8 @@ class Publication(Subscription):
self.auth_required = auth_required self.auth_required = auth_required
self.authentication_format = authentication_format self.authentication_format = authentication_format
self.authentication_type = authentication_type self.authentication_type = authentication_type
self.setSyncContentType(sync_content_type)
self.setSynchronizeWithERP5Sites(synchronize_with_erp5_sites)
def getPublicationUrl(self): def getPublicationUrl(self):
""" """
...@@ -238,6 +231,7 @@ class Publication(Subscription): ...@@ -238,6 +231,7 @@ class Publication(Subscription):
""" """
Add a new subscriber to the publication Add a new subscriber to the publication
""" """
LOG('addSubscriber starting ...',0,'')
# We have to remove the subscriber if it already exist (there were probably a reset on the client) # We have to remove the subscriber if it already exist (there were probably a reset on the client)
self.delSubscriber(subscriber.getSubscriptionUrl()) self.delSubscriber(subscriber.getSubscriptionUrl())
new_id = subscriber.getId() new_id = subscriber.getId()
......
...@@ -575,6 +575,7 @@ def addSubscription( self, id, title='', REQUEST=None ): ...@@ -575,6 +575,7 @@ def addSubscription( self, id, title='', REQUEST=None ):
""" """
Add a new Subscribption Add a new Subscribption
""" """
LOG('addSubscription starting...',0,'')
o = Subscription( id ,'','','','','','') o = Subscription( id ,'','','','','','')
self._setObject( id, o ) self._setObject( id, o )
if REQUEST is not None: if REQUEST is not None:
...@@ -648,7 +649,8 @@ class Subscription(Folder, SyncCode): ...@@ -648,7 +649,8 @@ class Subscription(Folder, SyncCode):
def __init__(self, id, title, publication_url, subscription_url, def __init__(self, id, title, publication_url, subscription_url,
destination_path, source_uri, target_uri, query, xml_mapping, destination_path, source_uri, target_uri, query, xml_mapping,
conduit, gpg_key, id_generator, gid_generator, media_type, login, conduit, gpg_key, id_generator, gid_generator, media_type, login,
password, activity_enabled, alert_code): password, activity_enabled, alert_code, synchronize_with_erp5_sites,
sync_content_type):
""" """
We need to create a dictionnary of We need to create a dictionnary of
signatures of documents which belong to the synchronisation signatures of documents which belong to the synchronisation
...@@ -679,7 +681,8 @@ class Subscription(Folder, SyncCode): ...@@ -679,7 +681,8 @@ class Subscription(Folder, SyncCode):
self.setConduit(conduit) self.setConduit(conduit)
Folder.__init__(self, id) Folder.__init__(self, id)
self.title = title self.title = title
self.setSyncContentType(sync_content_type)
self.setSynchronizeWithERP5Sites(synchronize_with_erp5_sites)
#self.signatures = PersitentMapping() #self.signatures = PersitentMapping()
def getAlertCodeList(self): def getAlertCodeList(self):
...@@ -727,7 +730,7 @@ class Subscription(Folder, SyncCode): ...@@ -727,7 +730,7 @@ class Subscription(Folder, SyncCode):
def getSourceURI(self): def getSourceURI(self):
""" """
getter for the source_uri (the local path of the subscription) getter for the source_uri (the local path of the subscription data base)
""" """
return getattr(self, 'source_uri', None) return getattr(self, 'source_uri', None)
...@@ -739,11 +742,26 @@ class Subscription(Folder, SyncCode): ...@@ -739,11 +742,26 @@ class Subscription(Folder, SyncCode):
def getTargetURI(self): def getTargetURI(self):
""" """
getter for the target_uri (the distant Publication we want to synchronize getter for the target_uri (the distant Publication data base we want to
with) synchronize with)
""" """
return getattr(self, 'target_uri', None) return getattr(self, 'target_uri', None)
def setSyncContentType(self, sync_content_type):
"""
content type used by the subscriber
"""
self.sync_content_type=sync_content_type
# the varible name is sync_content_type instead of content_type because
# content_type seems to be a function name already used
def getSyncContentType(self):
"""
getter of the subscriber sync_content_type
"""
return getattr(self, 'sync_content_type', 'application/vnd.syncml+xml')
def getSynchronizationType(self, default=None): def getSynchronizationType(self, default=None):
""" """
""" """
...@@ -770,6 +788,21 @@ class Subscription(Folder, SyncCode): ...@@ -770,6 +788,21 @@ class Subscription(Folder, SyncCode):
value = None value = None
self.xml_mapping = value self.xml_mapping = value
def setSynchronizeWithERP5Sites(self, synchronize_with_erp5_sites):
"""
if the synchronisation is made with another ERP5 site,
synchronize_with_erp5_sites is True, False in other case
XXX in the future, the method used to sendHttpResponse will be the same
in all cases, so this method will be useless
"""
self.synchronize_with_erp5_sites = synchronize_with_erp5_sites
def getSynchronizeWithERP5Sites(self):
"""
return True if the synchronisation is between two erp5 sites
"""
return getattr(self, 'synchronize_with_erp5_sites', None)
def checkCorrectRemoteSessionId(self, session_id): def checkCorrectRemoteSessionId(self, session_id):
""" """
We will see if the last session id was the same We will see if the last session id was the same
...@@ -886,7 +919,7 @@ class Subscription(Folder, SyncCode): ...@@ -886,7 +919,7 @@ class Subscription(Folder, SyncCode):
def setPublicationUrl(self, publication_url): def setPublicationUrl(self, publication_url):
""" """
return the publication url set the publication url
""" """
self.publication_url = publication_url self.publication_url = publication_url
...@@ -1058,6 +1091,30 @@ class Subscription(Folder, SyncCode): ...@@ -1058,6 +1091,30 @@ class Subscription(Folder, SyncCode):
break break
return o return o
def getObjectFromRid(self, rid):
"""
return the object corresponding to the id
"""
signature = self.getSignatureFromRid(rid)
destination = self.getDestination()
o = None
if signature is not None and signature.getPath() is not None:
try:
o = destination.getPortalObject().restrictedTraverse(signature.getPath())
except:
pass
return o
# def setOneWaySyncFromServer(self,value):
# """
# If this option is enabled, then we will not
# send our own modifications
# """
# self.one_way_sync_from_server = value
#
def getObjectList(self, **kw): def getObjectList(self, **kw):
""" """
This returns the list of sub-object corresponding This returns the list of sub-object corresponding
......
...@@ -75,7 +75,8 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -75,7 +75,8 @@ class SubscriptionSynchronization(XMLSyncUtils):
self.sendResponse(from_url=subscription.subscription_url, self.sendResponse(from_url=subscription.subscription_url,
to_url=subscription.publication_url, sync_id=subscription.getTitle(), to_url=subscription.publication_url, sync_id=subscription.getTitle(),
xml=xml_a,domain=subscription) xml=xml_a,domain=subscription,
content_type=subscription.getSyncContentType())
return {'has_response':1,'xml':xml_a} return {'has_response':1,'xml':xml_a}
...@@ -86,7 +87,7 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -86,7 +87,7 @@ class SubscriptionSynchronization(XMLSyncUtils):
response = None #check if subsync replies to this messages response = None #check if subsync replies to this messages
subscription = self.unrestrictedTraverse(subscription_path) subscription = self.unrestrictedTraverse(subscription_path)
if msg==None and (subscription.getSubscriptionUrl()).find('file')>=0: if msg==None and (subscription.getSubscriptionUrl()).find('file')>=0:
msg = self.readResponse(sync_id=subscription.getSourceURI(), msg = self.readResponse(sync_id=subscription.getSubscriptionUrl(),
from_url=subscription.getSubscriptionUrl()) from_url=subscription.getSubscriptionUrl())
if msg==None: if msg==None:
response = self.SubSyncInit(subscription) response = self.SubSyncInit(subscription)
...@@ -170,7 +171,8 @@ class SubscriptionSynchronization(XMLSyncUtils): ...@@ -170,7 +171,8 @@ class SubscriptionSynchronization(XMLSyncUtils):
self.sendResponse(from_url=subscription.subscription_url, self.sendResponse(from_url=subscription.subscription_url,
to_url=subscription.publication_url, sync_id=subscription.getTitle(), to_url=subscription.publication_url, sync_id=subscription.getTitle(),
xml=xml_a,domain=subscription) xml=xml_a,domain=subscription,
content_type=subscription.getSyncContentType())
return {'has_response':1,'xml':xml_a} return {'has_response':1,'xml':xml_a}
......
...@@ -37,8 +37,9 @@ class SyncCode(Persistent): ...@@ -37,8 +37,9 @@ class SyncCode(Persistent):
# SyncML Alert Codes # SyncML Alert Codes
TWO_WAY = 200 TWO_WAY = 200
SLOW_SYNC = 201 # This means we get the data from the publication SLOW_SYNC = 201 # This means we get the data from the publication
WAITING_DATA = 214
ONE_WAY_FROM_SERVER = 204 ONE_WAY_FROM_SERVER = 204
WAITING_DATA = 214
REFRESH_REQUIRED = 508
# SyncML Status Codes # SyncML Status Codes
SUCCESS = 200 SUCCESS = 200
...@@ -121,3 +122,9 @@ class SyncCode(Persistent): ...@@ -121,3 +122,9 @@ class SyncCode(Persistent):
MEDIA_TYPE = {} MEDIA_TYPE = {}
MEDIA_TYPE['TEXT_XML'] = 'text/xml' MEDIA_TYPE['TEXT_XML'] = 'text/xml'
MEDIA_TYPE['TEXT_VCARD'] = 'text/vcard' MEDIA_TYPE['TEXT_VCARD'] = 'text/vcard'
MEDIA_TYPE['TEXT_XVCARD'] = 'text/x-vcard'
#content types :
CONTENT_TYPE = {}
CONTENT_TYPE['SYNCML_XML'] = 'application/vnd.syncml+xml'
CONTENT_TYPE['SYNCML_WBXML'] = 'application/vnd.syncml+wbxml'
This diff is collapsed.
This diff is collapsed.
...@@ -55,6 +55,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -55,6 +55,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<b>Query :</b> the type of objects you want to synchronize</br> <b>Query :</b> the type of objects you want to synchronize</br>
<b>XML Mapping :</b> the page template used on each object before <b>XML Mapping :</b> the page template used on each object before
an export</br> an export</br>
<b>Synchronize with other ERP5 sites :</b> The method currently used
to send data to erp5 and external sites is not the same (it will be
improved soon)</br>
<b>Content Type :</b> the type of content use to exchange data
(could be 'application/vnd.syncml+wbxml' or
'application/vnd.syncml+xml' for example)</br>
<b>Conduit :</b> the conduit used to synchronize</br> <b>Conduit :</b> the conduit used to synchronize</br>
<b>GPG key name :</b>a name of gpg key to use</br> <b>GPG key name :</b>a name of gpg key to use</br>
<b>Id Generator :</b> This set the method name wich allows to <b>Id Generator :</b> This set the method name wich allows to
...@@ -80,6 +86,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -80,6 +86,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<b>Query :</b> the type of objects you want to synchronize</br> <b>Query :</b> the type of objects you want to synchronize</br>
<b>XML Mapping :</b> the page template used on each object before <b>XML Mapping :</b> the page template used on each object before
an export</br> an export</br>
<b>Synchronize with other ERP5 sites :</b> The method currently used
to send data to erp5 and external sites is not the same (it will be
improved soon)</br>
<b>Content Type :</b> the type of content use to exchange data
(could be 'application/vnd.syncml+wbxml' or
'application/vnd.syncml+xml' for example)</br>
<b>Conduit :</b> the conduit used to synchronize</br> <b>Conduit :</b> the conduit used to synchronize</br>
<b>GPG key name :</b>a name of gpg key to use</br> <b>GPG key name :</b>a name of gpg key to use</br>
<b>Id Generator :</b> This set the method name wich allows to <b>Id Generator :</b> This set the method name wich allows to
......
...@@ -108,6 +108,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -108,6 +108,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" value="<dtml-var getXMLMapping>" size="40" /> <input type="text" name="xml_mapping" value="<dtml-var getXMLMapping>" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1" <dtml-if expr="getSynchronizeWithERP5Sites()">CHECKED</dtml-if>>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" value="<dtml-var getSyncContentType>" size="40" />
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -144,6 +144,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -144,6 +144,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" value="<dtml-var getXMLMapping>" size="40" /> <input type="text" name="xml_mapping" value="<dtml-var getXMLMapping>" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1" <dtml-if expr="getSynchronizeWithERP5Sites()">CHECKED</dtml-if>>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" value="<dtml-var getSyncContentType>" size="40" />
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -103,6 +103,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -103,6 +103,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" size="40" /> <input type="text" name="xml_mapping" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" size="40" />
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
...@@ -140,6 +140,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -140,6 +140,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<input type="text" name="xml_mapping" size="40" /> <input type="text" name="xml_mapping" size="40" />
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Synchronize with other ERP5 sites
</label></div>
</td>
<td align="left" valign="top">
<input type="checkbox" name="synchronize_with_erp5_sites" value="1">
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Content Type
</label></div>
</td>
<td align="left" valign="top">
<input type="text" name="sync_content_type" size="40" />
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
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