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