Commit b8d1eaa5 authored by Jérome Perrin's avatar Jérome Perrin

syncml: fix issues raised by coding style test

Rename SQLCatalog_indexSyncMLDocumentList to ERP5Site_indexSyncMLDocumentList

Rename SyncMLDocument_updateURLToCurrentSite to SyncMLSubscription_updateURLToCurrentSite

Rename SyncML_searchFolder to SyncMLSubscription_searchFolder

Rename SynchronizationTool_viewPointFixe to SynchronizationTool_viewPointFixeDialog
parent 20afa613
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/SyncMLDocument_updateURLToCurrentSite</string> </value> <value> <string>string:${object_url}/SyncMLSubscription_updateURLToCurrentSite</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/SyncMLDocument_updateURLToCurrentSite</string> </value> <value> <string>string:${object_url}/SyncMLSubscription_updateURLToCurrentSite</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -651,7 +651,7 @@ class SyncMLSubscription(XMLObject): ...@@ -651,7 +651,7 @@ class SyncMLSubscription(XMLObject):
next_anchor=self.getNextAnchor()) next_anchor=self.getNextAnchor())
# Index signature with their new value # Index signature with their new value
if len(path_list): if len(path_list):
self.SQLCatalog_indexSyncMLDocumentList(path_list) self.ERP5Site_indexSyncMLDocumentList(path_list)
def _sendFinalMessage(self): def _sendFinalMessage(self):
""" """
...@@ -1199,7 +1199,7 @@ class SyncMLSubscription(XMLObject): ...@@ -1199,7 +1199,7 @@ class SyncMLSubscription(XMLObject):
else: else:
kw = {} kw = {}
self.getAndIndex( self.getAndIndex(
callback="SQLCatalog_indexSyncMLDocumentList", callback="ERP5Site_indexSyncMLDocumentList",
method_kw={'subscription_path' : self.getRelativeUrl()}, method_kw={'subscription_path' : self.getRelativeUrl()},
activate_kw=activate_kw, activate_kw=activate_kw,
**kw **kw
...@@ -1207,7 +1207,7 @@ class SyncMLSubscription(XMLObject): ...@@ -1207,7 +1207,7 @@ class SyncMLSubscription(XMLObject):
else: else:
r = [x.getPath() for x in self.getDocumentList()] r = [x.getPath() for x in self.getDocumentList()]
syncml_logger.info("indexing data from %s : %r", self.getPath(), r) syncml_logger.info("indexing data from %s : %r", self.getPath(), r)
portal.SQLCatalog_indexSyncMLDocumentList( portal.ERP5Site_indexSyncMLDocumentList(
path_list=r[:], path_list=r[:],
subscription_path=self.getRelativeUrl()) subscription_path=self.getRelativeUrl())
......
...@@ -25,12 +25,13 @@ ...@@ -25,12 +25,13 @@
# #
############################################################################## ##############################################################################
import base64 import base64
import six
from lxml import etree from lxml import etree
from difflib import unified_diff from difflib import unified_diff
from erp5.component.module.DiffUtils import DiffFile from erp5.component.module.DiffUtils import DiffFile
def diffXML(xml_plugin="", xml_erp5="", gid="", html=True): def diffXML(xml_plugin="", xml_erp5="", gid="", html=True):
if isinstance(xml_erp5, unicode): if isinstance(xml_erp5, six.text_type):
xml_erp5 = xml_erp5.encode('utf-8') xml_erp5 = xml_erp5.encode('utf-8')
if xml_plugin == "": if xml_plugin == "":
xml_plugin="<object>Not found</object>" xml_plugin="<object>Not found</object>"
...@@ -39,15 +40,15 @@ def diffXML(xml_plugin="", xml_erp5="", gid="", html=True): ...@@ -39,15 +40,15 @@ def diffXML(xml_plugin="", xml_erp5="", gid="", html=True):
try: try:
xml = etree.fromstring(xml_erp5) xml = etree.fromstring(xml_erp5)
xml_erp5 = etree.tostring(xml, pretty_print=True, encoding="utf-8") xml_erp5 = etree.tostring(xml, pretty_print=True, encoding="utf-8")
except etree.XMLSyntaxError: except etree.XMLSyntaxError: # pylint:disable=catching-non-exception
pass pass
if isinstance(xml_plugin, unicode): if isinstance(xml_plugin, six.text_type):
xml_plugin = xml_plugin.encode('utf-8') xml_plugin = xml_plugin.encode('utf-8')
try: try:
xml = etree.fromstring(xml_plugin) xml = etree.fromstring(xml_plugin)
xml_plugin = etree.tostring(xml, pretty_print=True, encoding="utf-8") xml_plugin = etree.tostring(xml, pretty_print=True, encoding="utf-8")
except etree.XMLSyntaxError: except etree.XMLSyntaxError: # pylint:disable=catching-non-exception
pass pass
diff_list = list(unified_diff(xml_plugin.split('\n'), xml_erp5.split('\n'), tofile="erp5 xml", fromfile="plugin xml", lineterm='')) diff_list = list(unified_diff(xml_plugin.split('\n'), xml_erp5.split('\n'), tofile="erp5 xml", fromfile="plugin xml", lineterm=''))
......
...@@ -74,35 +74,6 @@ ...@@ -74,35 +74,6 @@
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>validate</string> </value> <value> <string>validate</string> </value>
</item> </item>
<item>
<key> <string>actor</string> </key>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1377844521.87</float>
<string>GMT+9</string>
</tuple>
</state>
</object>
</value>
</item>
<item> <item>
<key> <string>validation_state</string> </key> <key> <string>validation_state</string> </key>
<value> <string>validated</string> </value> <value> <string>validated</string> </value>
......
...@@ -156,7 +156,7 @@ class SyncMLEngineMixin(object): ...@@ -156,7 +156,7 @@ class SyncMLEngineMixin(object):
else: else:
raise ValueError("Unknown status command : %r" % (status['command'],)) raise ValueError("Unknown status command : %r" % (status['command'],))
if len(path_list): if len(path_list):
domain.SQLCatalog_indexSyncMLDocumentList(path_list) domain.ERP5Site_indexSyncMLDocumentList(path_list)
return sync_status_counter return sync_status_counter
# #
......
...@@ -626,7 +626,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -626,7 +626,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if xml is a string, convert it to a node if xml is a string, convert it to a node
""" """
if xml is None: if xml is None:
return None return None
if isinstance(xml, six.string_types + (bytes, )): if isinstance(xml, six.string_types + (bytes, )):
if six.PY2 and isinstance(xml, six.text_type): if six.PY2 and isinstance(xml, six.text_type):
xml = xml.encode('utf-8') xml = xml.encode('utf-8')
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# #
############################################################################## ##############################################################################
from xml.dom.ext import PrettyPrint from xml.dom.ext import PrettyPrint # pylint:disable=no-name-in-module,import-error
import random import random
from six.moves import cStringIO as StringIO from six.moves import cStringIO as StringIO
......
...@@ -82,7 +82,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin): ...@@ -82,7 +82,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin):
# Make sure it is launched after indexation step # Make sure it is launched after indexation step
self.runGetAndActivate(subscription=subscription, tag=tag, self.runGetAndActivate(subscription=subscription, tag=tag,
after_method_id=("getAndIndex", after_method_id=("getAndIndex",
"SQLCatalog_indexSyncMLDocumentList")) "ERP5Site_indexSyncMLDocumentList"))
syncml_logger.info("X-> Client is sendind modification in activities") syncml_logger.info("X-> Client is sendind modification in activities")
# As we generated all activities to send data at once, process must not # As we generated all activities to send data at once, process must not
# go back here, go into processing state thus status will be applied and # go back here, go into processing state thus status will be applied and
...@@ -211,7 +211,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin): ...@@ -211,7 +211,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin):
# Start to send modification only once we have processed # Start to send modification only once we have processed
# all message from client # all message from client
after_method_id=('processServerSynchronization', after_method_id=('processServerSynchronization',
'SQLCatalog_indexSyncMLDocumentList') 'ERP5Site_indexSyncMLDocumentList')
# XXX after tag might also be required to make sure all data are indexed # XXX after tag might also be required to make sure all data are indexed
tag = (tag, "%s_reset" % subscriber.getPath(),) tag = (tag, "%s_reset" % subscriber.getPath(),)
# Do not continue in elif, as sending modifications is done in the same # Do not continue in elif, as sending modifications is done in the same
......
...@@ -60,7 +60,7 @@ def encode(format, string_to_encode): # pylint: disable=redefined-builtin ...@@ -60,7 +60,7 @@ def encode(format, string_to_encode): # pylint: disable=redefined-builtin
return string_to_encode return string_to_encode
if format == 'b64': if format == 'b64':
if not isinstance(string_to_encode, six.binary_type): if not isinstance(string_to_encode, six.binary_type):
string_to_encode = string_to_encode.encode() string_to_encode = string_to_encode.encode()
encoded = b64encode(string_to_encode) encoded = b64encode(string_to_encode)
return encoded return encoded
#elif format is .... put here the other formats #elif format is .... put here the other formats
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
from erp5.component.module.XMLSyncUtils import XMLSyncUtilsMixin from erp5.component.module.XMLSyncUtils import XMLSyncUtilsMixin
from xml.dom.ext.reader.Sax2 import FromXml from xml.dom.ext.reader.Sax2 import FromXml # pylint:disable=no-name-in-module,import-error
class XupdateUtils(XMLSyncUtilsMixin): class XupdateUtils(XMLSyncUtilsMixin):
""" """
......
...@@ -15,16 +15,16 @@ def generateParameterList(): ...@@ -15,16 +15,16 @@ def generateParameterList():
parameter_append_list = [] parameter_append_list = []
append = parameter_append_list.append append = parameter_append_list.append
parameter_dict = {} parameter_dict = {}
for property in method.arguments_src.split(): for prop in method.arguments_src.split():
parameter_dict[property] = parameter_value_list = [] parameter_dict[prop] = parameter_value_list = []
if property == 'getData': if prop == 'getData':
getter = getData getter = getData
elif property == 'getId': elif prop == 'getId':
getter = getId getter = getId
else: else:
getter = None getter = None
if getter is None: if getter is None:
getter = lambda obj, property=property: getattr(obj, property)() getter = lambda obj, prop=prop: getattr(obj, prop)()
append((parameter_value_list, getter)) append((parameter_value_list, getter))
return parameter_dict, parameter_append_list return parameter_dict, parameter_append_list
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SQLCatalog_indexSyncMLDocumentList</string> </value> <value> <string>ERP5Site_indexSyncMLDocumentList</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -8,12 +8,12 @@ parameters_N = '' ...@@ -8,12 +8,12 @@ parameters_N = ''
try: try:
first_name.encode('utf-8') first_name.encode('utf-8')
except: except UnicodeEncodeError:
parameters_FN = ';ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8' parameters_FN = ';ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8'
try: try:
last_name.encode('utf-8') last_name.encode('utf-8')
except: except UnicodeEncodeError:
parameters_N = ';ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8' parameters_N = ';ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8'
append = vcard_string_list.append append = vcard_string_list.append
......
from Products.CMFCore.utils import getToolByName
context.resetSubscriberList() context.resetSubscriberList()
message = context.Base_translateString('Publication reseting') message = context.Base_translateString('Publication reset')
return context.Base_redirect(form_id, keep_items={'portal_status_message' : message}, **kw) return context.Base_redirect(form_id, keep_items={'portal_status_message' : message}, **kw)
...@@ -74,9 +74,7 @@ ...@@ -74,9 +74,7 @@
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list> <list/>
<string>my_validatation_state</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -98,6 +96,7 @@ ...@@ -98,6 +96,7 @@
<value> <value>
<list> <list>
<string>my_data</string> <string>my_data</string>
<string>my_translated_validatation_state_title</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_validatation_state</string> </value> <value> <string>my_translated_validatation_state_title</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
...@@ -9,8 +9,8 @@ if active_process is None: ...@@ -9,8 +9,8 @@ if active_process is None:
portal_type='Active Process', portal_type='Active Process',
sort_on=(('creation_date', 'DESC'), sort_on=(('creation_date', 'DESC'),
# XXX Work around poor resolution of MySQL dates. # XXX Work around poor resolution of MySQL dates.
('CONVERT(`catalog`.`id`, UNSIGNED)', 'DESC')), ('id', 'DESC', 'UNSIGNED')),
causality_uid=sub.getUid()) causality_uid=context.getUid())
else: else:
active_process = context.getPortalObject().restrictedTraverse(active_process) active_process = context.getPortalObject().restrictedTraverse(active_process)
......
from Products.CMFCore.utils import getToolByName
context.resetSignatureList() context.resetSignatureList()
context.resetAnchorList() context.resetAnchorList()
message = context.Base_translateString('Subscription reseting') message = context.Base_translateString('Subscription reset')
return context.Base_redirect(form_id, keep_items={'portal_status_message' : message}, **kw) return context.Base_redirect(form_id, keep_items={'portal_status_message' : message}, **kw)
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SyncML_searchFolder</string> </value> <value> <string>SyncMLSubscription_searchFolder</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SyncMLDocument_updateURLToCurrentSite</string> </value> <value> <string>SyncMLSubscription_updateURLToCurrentSite</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
<string>my_next_anchor</string> <string>my_next_anchor</string>
<string>my_translated_portal_type</string> <string>my_translated_portal_type</string>
<string>my_translated_validation_state_title</string> <string>my_translated_validation_state_title</string>
<string>my_synchronization_state_title</string> <string>my_translated_synchronization_state_title</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_synchronization_state_title</string> </value> <value> <string>my_translated_synchronization_state_title</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
......
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SynchronizationTool_viewPointFixe</string> </value> <value> <string>SynchronizationTool_viewPointFixeDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>method</string> </key> <key> <string>method</string> </key>
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
</item> </item>
<item> <item>
<key> <string>name</string> </key> <key> <string>name</string> </key>
<value> <string>SynchronizationTool_viewPointFixe</string> </value> <value> <string>SynchronizationTool_viewPointFixeDialog</string> </value>
</item> </item>
<item> <item>
<key> <string>pt</string> </key> <key> <string>pt</string> </key>
......
...@@ -363,7 +363,7 @@ class SynchronizationTool(BaseTool): ...@@ -363,7 +363,7 @@ class SynchronizationTool(BaseTool):
activity="SQLQueue", activity="SQLQueue",
after_method_id=('processServerSynchronization', after_method_id=('processServerSynchronization',
'getAndIndex', 'getAndIndex',
'SQLCatalog_indexSyncMLDocumentList'), 'ERP5Site_indexSyncMLDocumentList'),
priority=ACTIVITY_PRIORITY, priority=ACTIVITY_PRIORITY,
tag=subscription.getRelativeUrl()).sendMessage(bytes(syncml_response)) tag=subscription.getRelativeUrl()).sendMessage(bytes(syncml_response))
else: else:
......
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
</item> </item>
<item> <item>
<key> <string>list_method_id</string> </key> <key> <string>list_method_id</string> </key>
<value> <string>SyncML_searchFolder</string> </value> <value> <string>SyncMLSubscription_searchFolder</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
</item> </item>
<item> <item>
<key> <string>list_method_id</string> </key> <key> <string>list_method_id</string> </key>
<value> <string>SyncML_searchFolder</string> </value> <value> <string>SyncMLSubscription_searchFolder</string> </value>
</item> </item>
<item> <item>
<key> <string>next_anchor</string> </key> <key> <string>next_anchor</string> </key>
......
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