Commit 7c6a9ebd authored by Nicolas Delaby's avatar Nicolas Delaby

SyncML Class refactoring: call activate on Sub an Pub objects, for scalability improvements

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15774 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 16b8f49f
master allow_login_change allow_login_change_differentiate_id_and_login allow_login_change_wip arnau arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc auto_extend_select_list autoflake backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog boc-interaction-drop cache catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos certificate_authority cherry-pick-4a8e045d cleanJSByJSLint clean_up_upgrader cleanup_acquisition_base_category compact_title_no_reference credential_update_action datetimefield deferred_listbox delivery_item_barcode douglas_forum dream_distributor drop-legacy-simulation dsn-phase3 eos-dev erp5-component erp5-data-notebook erp5-forum erp5-preference erp5-release erp5-slapos-upgrade erp5-util-testing erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_catalog erp5_free_subscription erp5_workflow erp5testnode_max_timeout experiment/coding_style_test_suite feat/accounting_balance_sheet_profit_and_loss_cleanups feat/accounting_stop_using_getObject feat/accounting_translate_gap feat/no_useless_records_in_predicate_table feat/trade_shipment_report feat/wendelin-py-data feature/renderjs-ui-no-header fix-wallsearch-cachename fix/full_text_script_conflict fix/lint_erp5_accounting fix/login_validate_check_consistency fix/repair_graph_editor fix/xvfb_all_displays_locked fix_system_processes_ownership for_testrunner_1 for_testrunner_2 for_testrunner_3 formbox gabriel gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value http_cache_fix improve_default_caching_policy_manager interaction-drop isDeletable item_tracking_graph_editor ivan jerome-bt-reference-doc jerome-test jerome_events jerome_graph_editor_renderjs jerome_new_style_solve_divergence jerome_promise_in_tests jerome_user_preference_time_zone jio jm/form-action-guard joblib-activity kns kns-kr lazy_simulation_causality lignan lingnan listbox-generator mame mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work mame2 maste_copy master-erp5-test-result-scalability master-erp5-test-result-scalability-rebase master-test-fix-additionalbt5path master_calendar_wip_patches master_calendar_wip_patches_extend_security master_no_guard_on_workflow_transition master_no_guard_on_workflow_transition_plus_calendar_wip_patchs merge_xhtml_jquery mmariani-inventory mrp new-render-presentation nexedi-erp5-jp no_longer_simulated_state officejs officejs_clean officejs_rjs_wallsearch officejs_wallsearch officejs_zip pere portal_callables portal_solver_process_security_configuration preet_wallsearch preet_wallsearch_officejs presentation rebased_mrp reindex_calendar_after_change_calendar_exception reverse_logistics rewrite_test_21_AcquiredPortalType romain-fulltext scalability-master2 scalability-master2-rebase scalability-rebase shop-box simulation sms_more_than_140_characters strict_catalog sws_fix syncml taskdistribution-xmlrpc-binary test_page testnode_software_link timezones tmp/getInstalledBusinessTemplate_never_installed_bt tristan tristan-merge tristan-performance ttr ttrm upgradeSite view-aggregated-amounts vincent_officejs_wallsearch vivekpab_erp5webrenderjs_layoutconfig vivekpab_jabberclient vivekpab_renderjs_interfaces wallsearch-add-link-description wenjie wenjie_branch yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components yusei erp5.util-0.4.49 erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37 erp5.util-0.4.1 erp5.util-0.4 erp5.util-0.3 erp5.util-0.2 erp5.util-0.1
No related merge requests found
......@@ -69,7 +69,7 @@ class PublicationSynchronization(XMLSyncUtils):
last_anchor = self.getAlertLastAnchor(xml_client)
next_anchor = self.getAlertNextAnchor(xml_client)
alert = self.checkAlert(xml_client)
alert_code = self.getAlertCode(xml_client)
alert_code = self.getAlertCodeFromXML(xml_client)
cred = self.checkCred(xml_client)
#the source and the target of the subscriber are reversed compared
......@@ -222,7 +222,7 @@ class PublicationSynchronization(XMLSyncUtils):
if first_node.nodeName != "SyncML":
LOG('PubSync', INFO, 'This is not a SyncML Message')
raise ValueError, "Sorry, This is not a SyncML Message"
alert_code = self.getAlertCode(xml_client)
alert_code = self.getAlertCodeFromXML(xml_client)
# Get informations from the header
client_header = first_node.childNodes[1]
if client_header.nodeName != "SyncHdr":
......
......@@ -36,6 +36,7 @@ from Products.ERP5Type.Core.Folder import Folder
from Products.ERP5Type.Base import Base
from Products.ERP5Type import Permissions
from Products.ERP5Type import PropertySheet
from XMLSyncUtils import XMLSyncUtils
from DateTime import DateTime
from zLOG import LOG, DEBUG, INFO
......@@ -585,7 +586,7 @@ def addSubscription( self, id, title='', REQUEST=None ):
#class Subscription(SyncCode, Implicit):
#class Subscription(Folder, SyncCode, Implicit, Folder, Impli):
class Subscription(Folder, SyncCode):
class Subscription(Folder, XMLSyncUtils):
"""
Subscription hold the definition of a master ODB
from/to which a selection of objects will be synchronised
......
......@@ -173,23 +173,20 @@ class SynchronizationTool( SubscriptionSynchronization,
+ '?manage_tabs_message=Tool+updated.'
)
security.declareProtected(Permissions.ModifyPortalContent,
security.declareProtected(Permissions.ModifyPortalContent,
'manage_addPublication')
def manage_addPublication(self, title, publication_url,
destination_path, source_uri, query, xml_mapping,
conduit, gpg_key,
def manage_addPublication(self, title, publication_url,
destination_path, source_uri, query, xml_mapping,
conduit, gpg_key,
synchronization_id_generator=None,
media_type=None, authentication_format='b64',
authentication_type='syncml:auth-basic',
media_type=None, authentication_format='b64',
authentication_type='syncml:auth-basic',
RESPONSE=None, activity_enabled = False,
sync_content_type='application/vnd.syncml+xml',
sync_content_type='application/vnd.syncml+xml',
synchronize_with_erp5_sites=True):
"""
create a new publication
"""
#if not('publications' in self.objectIds()):
# publications = Folder('publications')
# self._setObject(publications.id, publications)
folder = self.getObjectContainer()
new_id = self.getPublicationIdFromTitle(title)
pub = Publication(new_id, title, publication_url,
......@@ -201,9 +198,6 @@ class SynchronizationTool( SubscriptionSynchronization,
activity_enabled, synchronize_with_erp5_sites,
sync_content_type)
folder._setObject( new_id, pub )
#if len(self.list_publications) == 0:
# self.list_publications = PersistentMapping()
#self.list_publications[id] = pub
if RESPONSE is not None:
RESPONSE.redirect('managePublications')
......
......@@ -57,8 +57,8 @@ except ImportError:
class XMLSyncUtilsMixin(SyncCode):
def SyncMLHeader(self, session_id, msg_id, target, source, target_name=None,
source_name=None, dataCred=None, authentication_format='b64',
def SyncMLHeader(self, session_id, msg_id, target, source, target_name=None,
source_name=None, dataCred=None, authentication_format='b64',
authentication_type='syncml:auth-basic'):
"""
Since the Header is always almost the same, this is the
......@@ -630,7 +630,7 @@ class XMLSyncUtilsMixin(SyncCode):
rid = map_item.xpath('string(.//Source/LocURI)').encode('utf-8')
signature.setRid(rid)
def getAlertCode(self, xml_stream):
def getAlertCodeFromXML(self, xml_stream):
"""
Return the value of the alert code inside the full syncml message
"""
......@@ -840,11 +840,11 @@ class XMLSyncUtilsMixin(SyncCode):
# If not we have to cut
LOG('getSyncMLData', DEBUG, 'object_path: %s' % '/'.join(object_path))
LOG('getSyncMLData', DEBUG, 'xml_mapping: %s' % str(domain.getXMLMapping()))
LOG('getSyncMLData', DEBUG, 'code: %s' % str(self.getAlertCode(remote_xml)))
LOG('getSyncMLData', DEBUG, 'code: %s' % str(self.getAlertCodeFromXML(remote_xml)))
LOG('getSyncMLData', DEBUG, 'gid_list: %s' % str(local_gid_list))
LOG('getSyncMLData', DEBUG, 'subscriber.getGidList: %s' % subscriber.getGidList())
LOG('getSyncMLData', DEBUG, 'hasSignature: %s' % str(subscriber.hasSignature(object_gid)))
LOG('getSyncMLData', DEBUG, 'alert_code == slowsync: %s' % str(self.getAlertCode(remote_xml) == self.SLOW_SYNC))
LOG('getSyncMLData', DEBUG, 'alert_code == slowsync: %s' % str(self.getAlertCodeFromXML(remote_xml) == self.SLOW_SYNC))
signature = subscriber.getSignatureFromGid(object_gid)
## Here we first check if the object was modified or not by looking at dates
......@@ -857,7 +857,7 @@ class XMLSyncUtilsMixin(SyncCode):
pass
elif signature is None or (signature.getXML() is None and \
signature.getStatus() != self.PARTIAL) or \
self.getAlertCode(remote_xml) == self.SLOW_SYNC:
self.getAlertCodeFromXML(remote_xml) == self.SLOW_SYNC:
LOG('getSyncMLData', DEBUG, 'Current object.getPath: %s' % object.getPath())
xml_object = domain.getXMLFromObject(object)
xml_string = xml_object
......@@ -1367,7 +1367,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
subscriber=subscriber,
remote_xml=remote_xml)
alert_code = self.getAlertCode(remote_xml)
alert_code = self.getAlertCodeFromXML(remote_xml)
# Import the conduit and get it
conduit = self.getConduitByName(subscriber.getConduit())
# Then apply the list of actions
......@@ -1426,7 +1426,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
string_io = StringIO()
PrettyPrint(remote_xml,stream=string_io)
remote_xml = string_io.getvalue()
self.activate(activity='SQLQueue').SyncModifActivity(
domain.activate(activity='SQLQueue').SyncModifActivity(
domain_relative_url = domain.getRelativeUrl(),
remote_xml = remote_xml,
subscriber_relative_url = subscriber.getRelativeUrl(),
......@@ -1469,7 +1469,7 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
kw['cmd_id'] = cmd_id
finished = result['finished']
if not finished:
self.activate(activity='SQLQueue').SyncModifActivity(**kw)
domain.activate(activity='SQLQueue').SyncModifActivity(**kw)
else:
xml_confirmation = result['xml_confirmation']
cmd_id = result['cmd_id']
......
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