Commit d2a9efab authored by Sebastien Robin's avatar Sebastien Robin

do not break the start of ERP5 if the library Ft.Xml is missing, only raise...

do not break the start of ERP5 if the library Ft.Xml is missing, only raise ImportError when we want to use synchronization tool

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14660 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7f61d51a
...@@ -33,7 +33,7 @@ from Products.CMFCore.utils import getToolByName ...@@ -33,7 +33,7 @@ from Products.CMFCore.utils import getToolByName
from Products.ERP5SyncML.XupdateUtils import XupdateUtils from Products.ERP5SyncML.XupdateUtils import XupdateUtils
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.Accessor.TypeDefinition import list_types from Products.ERP5Type.Accessor.TypeDefinition import list_types
from Ft.Xml import Parse from Products.ERP5SyncML.XMLSyncUtils import Parse
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
from email.MIMEBase import MIMEBase from email.MIMEBase import MIMEBase
from email import Encoders from email import Encoders
...@@ -47,11 +47,19 @@ from cStringIO import StringIO ...@@ -47,11 +47,19 @@ from cStringIO import StringIO
from xml.sax.saxutils import escape, unescape from xml.sax.saxutils import escape, unescape
import re, copy import re, copy
import cStringIO import cStringIO
from Ft.Xml.Domlette import Print, PrettyPrint
from zLOG import LOG from zLOG import LOG
try:
from Ft.Xml.Domlette import Print, PrettyPrint
except ImportError:
LOG('ERP5Conduit',0,"Can't import Print and PrettyPrint")
class Print:
def __init__(self, *args, **kw):
raise ImportError, "Sorry, it was not possible to import Ft library"
class PrettyPrint:
def __init__(self, *args, **kw):
raise ImportError, "Sorry, it was not possible to import Ft library"
class ERP5Conduit(XMLSyncUtilsMixin): class ERP5Conduit(XMLSyncUtilsMixin):
""" """
......
...@@ -154,7 +154,7 @@ class Publication(Subscription): ...@@ -154,7 +154,7 @@ class Publication(Subscription):
# Constructor # Constructor
def __init__(self, id, title, publication_url, destination_path, def __init__(self, id, title, publication_url, destination_path,
query, xml_mapping, conduit, gpg_key, id_generator, gid_generator, query, xml_mapping, conduit, gpg_key, id_generator, gid_generator,
flow_type, auth_required=False, authentication_format='', media_type, auth_required=False, authentication_format='',
authentication_type=''): authentication_type=''):
""" """
constructor constructor
...@@ -168,7 +168,7 @@ class Publication(Subscription): ...@@ -168,7 +168,7 @@ class Publication(Subscription):
self.domain_type = self.PUB self.domain_type = self.PUB
self.gpg_key = gpg_key self.gpg_key = gpg_key
self.setGidGenerator(gid_generator) self.setGidGenerator(gid_generator)
self.setFlowType(flow_type) self.setMediaType(media_type)
self.setSynchronizationIdGenerator(id_generator) self.setSynchronizationIdGenerator(id_generator)
self.setConduit(conduit) self.setConduit(conduit)
Folder.__init__(self, id) Folder.__init__(self, id)
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
import smtplib # to send emails import smtplib # to send emails
from Publication import Publication,Subscriber from Publication import Publication,Subscriber
from Subscription import Signature from Subscription import Signature
from Ft.Xml import Parse from XMLSyncUtils import Parse
from XMLSyncUtils import XMLSyncUtils from XMLSyncUtils import XMLSyncUtils
from Conduit.ERP5Conduit import ERP5Conduit from Conduit.ERP5Conduit import ERP5Conduit
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
......
...@@ -644,7 +644,7 @@ class Subscription(Folder, SyncCode): ...@@ -644,7 +644,7 @@ class Subscription(Folder, SyncCode):
# Constructor # Constructor
def __init__(self, id, title, publication_url, subscription_url, def __init__(self, id, title, publication_url, subscription_url,
destination_path, query, xml_mapping, conduit, gpg_key, id_generator, destination_path, query, xml_mapping, conduit, gpg_key, id_generator,
gid_generator, flow_type, login, password): gid_generator, media_type, login, password):
""" """
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
...@@ -661,7 +661,7 @@ class Subscription(Folder, SyncCode): ...@@ -661,7 +661,7 @@ class Subscription(Folder, SyncCode):
#self.signatures = PersistentMapping() #self.signatures = PersistentMapping()
self.last_anchor = '00000000T000000Z' self.last_anchor = '00000000T000000Z'
self.next_anchor = '00000000T000000Z' self.next_anchor = '00000000T000000Z'
self.flow_type = flow_type self.setMediaType(media_type)
self.login = login self.login = login
self.password=password self.password=password
self.domain_type = self.SUB self.domain_type = self.SUB
...@@ -884,19 +884,20 @@ class Subscription(Folder, SyncCode): ...@@ -884,19 +884,20 @@ class Subscription(Folder, SyncCode):
""" """
return self.gid_generator return self.gid_generator
def getFlowType(self): def getMediaType(self):
""" """
This method return the type of the data within the xml message : This method return the type of media used in this session,
- text for VCard's for example, it could be "text/vcard" or "xml/text",...
- xml for others
""" """
return getattr(self, 'flow_type', 'xml') return getattr(self, 'media_type', self.MEDIA_TYPE['TEXT_XML'])
def setFlowType(self, flow_type): def setMediaType(self, media_type):
""" """
set the flow type (xml or text) set the type of media used
""" """
self.flow_type=flow_type if media_type in (None,''):
media_type = self.MEDIA_TYPE['TEXT_XML']
self.media_type = media_type
def getLogin(self): def getLogin(self):
""" """
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
import smtplib # to send emails import smtplib # to send emails
from Subscription import Subscription,Signature from Subscription import Subscription,Signature
from Ft.Xml import Parse from XMLSyncUtils import XMLSyncUtils, Parse
from XMLSyncUtils import XMLSyncUtils
import commands import commands
from Conduit.ERP5Conduit import ERP5Conduit from Conduit.ERP5Conduit import ERP5Conduit
from zLOG import LOG from zLOG import LOG
......
...@@ -110,3 +110,10 @@ class SyncCode(Persistent): ...@@ -110,3 +110,10 @@ class SyncCode(Persistent):
bad_history_exp = "/%s\[@id='.*'\]/" % history_tag bad_history_exp = "/%s\[@id='.*'\]/" % history_tag
local_role_and_group_list = (local_group_exp,local_role_exp) local_role_and_group_list = (local_group_exp,local_role_exp)
bad_local_role_and_group_list = (bad_local_group_exp,bad_local_role_exp) bad_local_role_and_group_list = (bad_local_group_exp,bad_local_role_exp)
#media types :
MEDIA_TYPE = {}
MEDIA_TYPE['TEXT_XML'] = 'text/xml'
MEDIA_TYPE['TEXT_VCARD'] = 'text/vcard'
...@@ -40,7 +40,8 @@ from Products.ERP5SyncML import Conduit ...@@ -40,7 +40,8 @@ from Products.ERP5SyncML import Conduit
from Publication import Publication,Subscriber from Publication import Publication,Subscriber
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2 from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2
from Subscription import Subscription,Signature from Subscription import Subscription,Signature
from Ft.Xml import Parse from XMLSyncUtils import Parse
#from Ft.Xml import Parse
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
...@@ -162,7 +163,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -162,7 +163,7 @@ class SynchronizationTool( SubscriptionSynchronization,
def manage_addPublication(self, title, publication_url, destination_path, def manage_addPublication(self, title, publication_url, destination_path,
query, xml_mapping, conduit, gpg_key, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator=None, gid_generator=None, synchronization_id_generator=None, gid_generator=None,
flow_type='xml', auth_required=0, authentication_format='', media_type=None, auth_required=0, authentication_format='',
authentication_type='', RESPONSE=None): authentication_type='', RESPONSE=None):
""" """
create a new publication create a new publication
...@@ -174,7 +175,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -174,7 +175,7 @@ class SynchronizationTool( SubscriptionSynchronization,
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, conduit, gpg_key, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator, gid_generator, flow_type, synchronization_id_generator, gid_generator, media_type,
auth_required, authentication_format, authentication_type) auth_required, authentication_format, authentication_type)
folder._setObject( new_id, pub ) folder._setObject( new_id, pub )
#if len(self.list_publications) == 0: #if len(self.list_publications) == 0:
...@@ -188,7 +189,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -188,7 +189,7 @@ class SynchronizationTool( SubscriptionSynchronization,
def manage_addSubscription(self, title, publication_url, subscription_url, def manage_addSubscription(self, title, publication_url, subscription_url,
destination_path, query, xml_mapping, conduit, gpg_key, destination_path, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator=None, gid_generator=None, synchronization_id_generator=None, gid_generator=None,
flow_type='xml', login=None, password=None, media_type=None, login=None, password=None,
RESPONSE=None): RESPONSE=None):
""" """
XXX should be renamed as addSubscription XXX should be renamed as addSubscription
...@@ -201,7 +202,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -201,7 +202,7 @@ class SynchronizationTool( SubscriptionSynchronization,
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, conduit, gpg_key, destination_path, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator, gid_generator, flow_type, synchronization_id_generator, gid_generator, media_type,
login, password) login, password)
folder._setObject( new_id, sub ) folder._setObject( new_id, sub )
#if len(self.list_subscriptions) == 0: #if len(self.list_subscriptions) == 0:
...@@ -215,7 +216,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -215,7 +216,7 @@ class SynchronizationTool( SubscriptionSynchronization,
def manage_editPublication(self, title, publication_url, destination_path, def manage_editPublication(self, title, publication_url, destination_path,
query, xml_mapping, conduit, gpg_key, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator, gid_generator, synchronization_id_generator, gid_generator,
flow_type='xml', auth_required=0, media_type=None, auth_required=0,
authentication_format='', authentication_type='', authentication_format='', authentication_type='',
RESPONSE=None): RESPONSE=None):
""" """
...@@ -231,7 +232,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -231,7 +232,7 @@ class SynchronizationTool( SubscriptionSynchronization,
pub.setGPGKey(gpg_key) pub.setGPGKey(gpg_key)
pub.setSynchronizationIdGenerator(synchronization_id_generator) pub.setSynchronizationIdGenerator(synchronization_id_generator)
pub.setGidGenerator(gid_generator) pub.setGidGenerator(gid_generator)
pub.setFlowType(flow_type) pub.setMediaType(media_type)
pub.setAuthentication(auth_required) pub.setAuthentication(auth_required)
pub.setAuthenticationFormat(authentication_format) pub.setAuthenticationFormat(authentication_format)
pub.setAuthenticationType(authentication_type) pub.setAuthenticationType(authentication_type)
...@@ -243,7 +244,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -243,7 +244,7 @@ class SynchronizationTool( SubscriptionSynchronization,
'manage_editSubscription') 'manage_editSubscription')
def manage_editSubscription(self, title, publication_url, subscription_url, def manage_editSubscription(self, title, publication_url, subscription_url,
destination_path, query, xml_mapping, conduit, gpg_key, destination_path, query, xml_mapping, conduit, gpg_key,
synchronization_id_generator, gid_generator, flow_type='xml', login='', synchronization_id_generator, gid_generator, media_type=None,login='',
password='', RESPONSE=None): password='', RESPONSE=None):
""" """
modify a subscription modify a subscription
...@@ -259,7 +260,7 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -259,7 +260,7 @@ class SynchronizationTool( SubscriptionSynchronization,
sub.setSubscriptionUrl(subscription_url) sub.setSubscriptionUrl(subscription_url)
sub.setSynchronizationIdGenerator(synchronization_id_generator) sub.setSynchronizationIdGenerator(synchronization_id_generator)
sub.setGidGenerator(gid_generator) sub.setGidGenerator(gid_generator)
sub.setFlowType(flow_type) sub.setMediaType(media_type)
sub.setLogin(login) sub.setLogin(login)
sub.setPassword(password) sub.setPassword(password)
if RESPONSE is not None: if RESPONSE is not None:
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
import smtplib import smtplib
from Products.ERP5SyncML.SyncCode import SyncCode from Products.ERP5SyncML.SyncCode import SyncCode
from Products.ERP5SyncML.Subscription import Signature from Products.ERP5SyncML.Subscription import Signature
from Ft.Xml import Parse
from DateTime import DateTime from DateTime import DateTime
from cStringIO import StringIO from cStringIO import StringIO
from xml.dom.ext import PrettyPrint from xml.dom.ext import PrettyPrint
...@@ -42,6 +41,13 @@ except ImportError: ...@@ -42,6 +41,13 @@ except ImportError:
pass pass
import commands import commands
from zLOG import LOG from zLOG import LOG
try:
from Ft.Xml import Parse
except ImportError:
LOG('XMLSyncUtils',0,"Can't import Parse")
class Parse:
def __init__(self, *args, **kw):
raise ImportError, "Sorry, it was not possible to import Ft library"
class XMLSyncUtilsMixin(SyncCode): class XMLSyncUtilsMixin(SyncCode):
...@@ -191,7 +197,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -191,7 +197,7 @@ class XMLSyncUtilsMixin(SyncCode):
server.quit() server.quit()
def addXMLObject(self, cmd_id=0, object=None, xml_string=None, def addXMLObject(self, cmd_id=0, object=None, xml_string=None,
more_data=0,gid=None): more_data=0,gid=None, media_type=None):
""" """
Add an object with the SyncML protocol Add an object with the SyncML protocol
""" """
...@@ -200,7 +206,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -200,7 +206,7 @@ class XMLSyncUtilsMixin(SyncCode):
xml(' <Add>\n') xml(' <Add>\n')
xml(' <CmdID>%s</CmdID>\n' % cmd_id) xml(' <CmdID>%s</CmdID>\n' % cmd_id)
xml(' <Meta>\n') xml(' <Meta>\n')
xml(' <Type>%s</Type>\n' % object.portal_type) xml(' <Type>%s</Type>\n' % media_type)
xml(' </Meta>\n') xml(' </Meta>\n')
xml(' <Item>\n') xml(' <Item>\n')
xml(' <Source>\n') xml(' <Source>\n')
...@@ -236,7 +242,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -236,7 +242,7 @@ class XMLSyncUtilsMixin(SyncCode):
return xml_a return xml_a
def replaceXMLObject(self, cmd_id=0, object=None, xml_string=None, def replaceXMLObject(self, cmd_id=0, object=None, xml_string=None,
more_data=0,gid=None): more_data=0, gid=None, media_type=None):
""" """
Replace an object with the SyncML protocol Replace an object with the SyncML protocol
""" """
...@@ -245,7 +251,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -245,7 +251,7 @@ class XMLSyncUtilsMixin(SyncCode):
xml(' <Replace>\n') xml(' <Replace>\n')
xml(' <CmdID>%s</CmdID>\n' % cmd_id) xml(' <CmdID>%s</CmdID>\n' % cmd_id)
xml(' <Meta>\n') xml(' <Meta>\n')
xml(' <Type>%s</Type>\n' % object.portal_type) xml(' <Type>%s</Type>\n' % media_type)
xml(' </Meta>\n') xml(' </Meta>\n')
xml(' <Item>\n') xml(' <Item>\n')
xml(' <Source>\n') xml(' <Source>\n')
...@@ -663,6 +669,8 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -663,6 +669,8 @@ class XMLSyncUtilsMixin(SyncCode):
status = self.SENT status = self.SENT
#gid_generator = getattr(object,domain.getGidGenerator(),None) #gid_generator = getattr(object,domain.getGidGenerator(),None)
object_gid = domain.getGidFromObject(object) object_gid = domain.getGidFromObject(object)
if object_gid in ('', None):
continue;
local_gid_list += [object_gid] local_gid_list += [object_gid]
#if gid_generator is not None: #if gid_generator is not None:
# object_gid = gid_generator() # object_gid = gid_generator()
...@@ -670,7 +678,6 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -670,7 +678,6 @@ class XMLSyncUtilsMixin(SyncCode):
if syncml_data.count('\n') < self.MAX_LINES and not \ if syncml_data.count('\n') < self.MAX_LINES and not \
object.id.startswith('.'): # If not we have to cut object.id.startswith('.'): # If not we have to cut
#LOG('getSyncMLData',0,'xml_mapping: %s' % str(domain.xml_mapping)) #LOG('getSyncMLData',0,'xml_mapping: %s' % str(domain.xml_mapping))
#LOG('getSyncMLData', 0, 'FlowType: %s' % str(subscriber.getFlowType()))
#LOG('getSyncMLData',0,'code: %s' % str(self.getAlertCode(remote_xml))) #LOG('getSyncMLData',0,'code: %s' % str(self.getAlertCode(remote_xml)))
#LOG('getSyncMLData',0,'gid_list: %s' % str(local_gid_list)) #LOG('getSyncMLData',0,'gid_list: %s' % str(local_gid_list))
#LOG('getSyncMLData',0,'hasSignature: %s' % str(subscriber.hasSignature(object_gid))) #LOG('getSyncMLData',0,'hasSignature: %s' % str(subscriber.hasSignature(object_gid)))
...@@ -712,7 +719,8 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -712,7 +719,8 @@ class XMLSyncUtilsMixin(SyncCode):
signature.setAction('Add') signature.setAction('Add')
xml_string = '<!--' + short_string + '-->' xml_string = '<!--' + short_string + '-->'
syncml_data += self.addXMLObject(cmd_id=cmd_id, object=object, syncml_data += self.addXMLObject(cmd_id=cmd_id, object=object,
gid=object_gid, xml_string=xml_string, more_data=more_data) gid=object_gid, xml_string=xml_string, more_data=more_data,
media_type=subscriber.getMediaType())
cmd_id += 1 cmd_id += 1
signature.setStatus(status) signature.setStatus(status)
subscriber.addSignature(signature) subscriber.addSignature(signature)
...@@ -748,11 +756,12 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -748,11 +756,12 @@ class XMLSyncUtilsMixin(SyncCode):
signature.setAction('Replace') signature.setAction('Replace')
xml_string = '<!--' + short_string + '-->' xml_string = '<!--' + short_string + '-->'
signature.setStatus(status) signature.setStatus(status)
if(subscriber.getFlowType() == 'text'): if subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']:
xml_string = self.getXMLObject(object=object, xml_string = self.getXMLObject(object=object,
xml_mapping=domain.xml_mapping) xml_mapping=domain.xml_mapping)
syncml_data += self.replaceXMLObject(cmd_id=cmd_id, object=object, syncml_data += self.replaceXMLObject(cmd_id=cmd_id, object=object,
gid=object_gid, xml_string=xml_string, more_data=more_data) gid=object_gid, xml_string=xml_string, more_data=more_data,
media_type=subscriber.getMediaType())
cmd_id += 1 cmd_id += 1
signature.setTempXML(xml_object) signature.setTempXML(xml_object)
# Now we can apply the xupdate from the subscriber # Now we can apply the xupdate from the subscriber
...@@ -771,7 +780,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -771,7 +780,7 @@ class XMLSyncUtilsMixin(SyncCode):
signature.setStatus(self.SYNCHRONIZED) signature.setStatus(self.SYNCHRONIZED)
elif signature.getStatus()==self.PUB_CONFLICT_CLIENT_WIN: elif signature.getStatus()==self.PUB_CONFLICT_CLIENT_WIN:
# We have decided to apply the update # We have decided to apply the update
# XXX previous_xml will be getXML instead of getTempXML because # XXX previous_xml will be geXML instead of getTempXML because
# some modification was already made and the update # some modification was already made and the update
# may not apply correctly # may not apply correctly
xml_update = signature.getPartialXML() xml_update = signature.getPartialXML()
...@@ -798,16 +807,18 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -798,16 +807,18 @@ class XMLSyncUtilsMixin(SyncCode):
xml_string = xml_string.replace('--','@-@@-@') xml_string = xml_string.replace('--','@-@@-@')
xml_string = '<!--' + xml_string + '-->' xml_string = '<!--' + xml_string + '-->'
signature.setStatus(status) signature.setStatus(status)
if(subscriber.getFlowType() == 'text'): if(subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']):
xml_string = self.getXMLObject(object=object, xml_string = self.getXMLObject(object=object,
xml_mapping=domain.xml_mapping) xml_mapping=domain.xml_mapping)
LOG('xml_string =', 0, xml_string) LOG('xml_string =', 0, xml_string)
if signature.getAction()=='Replace': if signature.getAction()=='Replace':
syncml_data += self.replaceXMLObject(cmd_id=cmd_id, object=object, syncml_data += self.replaceXMLObject(cmd_id=cmd_id, object=object,
gid=object_gid, xml_string=xml_string, more_data=more_data) gid=object_gid, xml_string=xml_string, more_data=more_data,
media_type=subscriber.getMediaType())
elif signature.getAction()=='Add': elif signature.getAction()=='Add':
syncml_data += self.addXMLObject(cmd_id=cmd_id, object=object, syncml_data += self.addXMLObject(cmd_id=cmd_id, object=object,
gid=object_gid, xml_string=xml_string, more_data=more_data) gid=object_gid, xml_string=xml_string, more_data=more_data,
media_type=subscriber.getMediaType())
return (syncml_data,xml_confirmation,cmd_id) return (syncml_data,xml_confirmation,cmd_id)
def applyActionList(self, domain=None, subscriber=None,destination_path=None, def applyActionList(self, domain=None, subscriber=None,destination_path=None,
...@@ -846,12 +857,12 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -846,12 +857,12 @@ class XMLSyncUtilsMixin(SyncCode):
data_subnode = partial_data data_subnode = partial_data
LOG('SyncModif',0,'data_subnode: %s' % data_subnode) LOG('SyncModif',0,'data_subnode: %s' % data_subnode)
#data_subnode = FromXml(data_subnode) #data_subnode = FromXml(data_subnode)
if subscriber.getFlowType() == 'xml': if subscriber.getMediaType() == self.MEDIA_TYPE['TEXT_XML']:
data_subnode = Parse(data_subnode) data_subnode = Parse(data_subnode)
data_subnode = data_subnode.childNodes[0] # Because we just created a new xml data_subnode = data_subnode.childNodes[0] # Because we just created a new xml
# document, with childNodes[0] a DocumentType and childNodes[1] the Element Node # document, with childNodes[0] a DocumentType and childNodes[1] the Element Node
else: else:
if subscriber.getFlowType() == 'text': if subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']:
data_subnode = self.getDataText(next_action) data_subnode = self.getDataText(next_action)
else: else:
data_subnode = self.getDataSubNode(next_action) data_subnode = self.getDataSubNode(next_action)
...@@ -934,7 +945,7 @@ class XMLSyncUtilsMixin(SyncCode): ...@@ -934,7 +945,7 @@ class XMLSyncUtilsMixin(SyncCode):
elif next_action.nodeName == 'Delete': elif next_action.nodeName == 'Delete':
object_id = signature.getId() object_id = signature.getId()
if subscriber.getFlowType == 'text': if subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']:
data_subnode = self.getDataText(next_action) data_subnode = self.getDataText(next_action)
else: else:
data_subnode = self.getDataSubNode(next_action) data_subnode = self.getDataSubNode(next_action)
......
...@@ -130,19 +130,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -130,19 +130,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
Flow Type Media Type
</label></div> </label></div>
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
<SELECT name="flow_type" size="1"> <input type="text" name="media_type" value="<dtml-var getMediaType>" size="40" />
<dtml-if expr="getFlowType() != 'text'">
<OPTION value="xml" selected>XML</option>
<OPTION value="text">text</option>
<dtml-else>
<OPTION value="xml">XML</option>
<OPTION value="text" selected>text</option>
</dtml-if>
</SELECT>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -140,19 +140,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -140,19 +140,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
Flow Type Media Type
</label></div> </label></div>
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
<SELECT name="flow_type" size="1"> <input type="text" name="media_type" value="<dtml-var getMediaType>" size="40" />
<dtml-if expr="getFlowType() != 'text'">
<OPTION value="xml" selected>XML</option>
<OPTION value="text">text</option>
<dtml-else>
<OPTION value="xml">XML</option>
<OPTION value="text" selected>text</option>
</dtml-if>
</SELECT>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -126,14 +126,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -126,14 +126,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
Flow Type Media Type
</label></div> </label></div>
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
<SELECT name="flow_type" size="1"> <input type="text" name="media_type" size="40" />
<OPTION value="xml" selected>XML</option>
<OPTION value="text">text</option>
</SELECT>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -136,14 +136,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -136,14 +136,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
Flow Type Media Type
</label></div> </label></div>
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
<SELECT name="flow_type" size="1"> <input type="text" name="media_type" size="40" />
<OPTION value="xml" selected>XML</option>
<OPTION value="text">text</option>
</SELECT>
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -745,7 +745,7 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -745,7 +745,7 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
sub_person1.edit(**kw) sub_person1.edit(**kw)
sub_sub_person1 = sub_person1.newContent(id=self.id1,portal_type='Person') sub_sub_person1 = sub_person1.newContent(id=self.id1,portal_type='Person')
kw = {'first_name':self.first_name1,'last_name':self.last_name1, kw = {'first_name':self.first_name1,'last_name':self.last_name1,
'description':self.description1} 'description':self.description1, 'default_telephone_text':'0689778308'}
sub_sub_person1.edit(**kw) sub_sub_person1.edit(**kw)
sub_sub_person2 = sub_person1.newContent(id=self.id2,portal_type='Person') sub_sub_person2 = sub_person1.newContent(id=self.id2,portal_type='Person')
kw = {'first_name':self.first_name2,'last_name':self.last_name2, kw = {'first_name':self.first_name2,'last_name':self.last_name2,
...@@ -785,6 +785,7 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase): ...@@ -785,6 +785,7 @@ class TestERP5SyncML(TestERP5SyncMLMixin, ERP5TypeTestCase):
self.failUnless(sub_sub_person1.getDescription()==self.description1) self.failUnless(sub_sub_person1.getDescription()==self.description1)
self.failUnless(sub_sub_person1.getFirstName()==self.first_name1) self.failUnless(sub_sub_person1.getFirstName()==self.first_name1)
self.failUnless(sub_sub_person1.getLastName()==self.last_name1) self.failUnless(sub_sub_person1.getLastName()==self.last_name1)
self.failUnless(sub_sub_person1.getDefaultTelephoneText()=='+(0)-0689778308')
self.failUnless(sub_sub_person2.getDescription()==self.description2) self.failUnless(sub_sub_person2.getDescription()==self.description2)
self.failUnless(sub_sub_person2.getFirstName()==self.first_name2) self.failUnless(sub_sub_person2.getFirstName()==self.first_name2)
self.failUnless(sub_sub_person2.getLastName()==self.last_name2) self.failUnless(sub_sub_person2.getLastName()==self.last_name2)
......
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