Commit cfd20fd9 authored by Nicolas Delaby's avatar Nicolas Delaby

Use priority for activities

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24133 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a3e20c00
...@@ -230,8 +230,10 @@ class Publication(Subscription): ...@@ -230,8 +230,10 @@ class Publication(Subscription):
""" """
Reset all subscribers Reset all subscribers
""" """
for o in self.getSubscriberList(): id_list = [o.id for o in self.getSubscriberList()]
self.activate(activity='SQLQueue', tag=self.getId()).manage_delObjects(o.id) self.activate(activity='SQLQueue',
tag=self.getId(),
priority=self.PRIORITY).manage_delObjects(id_list)
def getConflictList(self): def getConflictList(self):
""" """
......
...@@ -1342,10 +1342,11 @@ class Subscription(Folder, XMLSyncUtils): ...@@ -1342,10 +1342,11 @@ class Subscription(Folder, XMLSyncUtils):
""" """
object_id_list = [id for id in self.getObjectIds()] object_id_list = [id for id in self.getObjectIds()]
object_list_len = len(object_id_list) object_list_len = len(object_id_list)
for i in xrange(0, object_list_len, 100): for i in xrange(0, object_list_len, self.MAX_OBJECTS):
current_id_list = object_id_list[i:i+100] current_id_list = object_id_list[i:i+self.MAX_OBJECTS]
self.activate(activity='SQLQueue', self.activate(activity='SQLQueue',
tag = self.getId()).manage_delObjects(current_id_list) tag=self.getId(),
priority=self.PRIORITY).manage_delObjects(current_id_list)
def getConflictList(self): def getConflictList(self):
""" """
......
...@@ -129,3 +129,6 @@ class SyncCode(Persistent): ...@@ -129,3 +129,6 @@ class SyncCode(Persistent):
CONTENT_TYPE = {} CONTENT_TYPE = {}
CONTENT_TYPE['SYNCML_XML'] = 'application/vnd.syncml+xml' CONTENT_TYPE['SYNCML_XML'] = 'application/vnd.syncml+xml'
CONTENT_TYPE['SYNCML_WBXML'] = 'application/vnd.syncml+wbxml' CONTENT_TYPE['SYNCML_WBXML'] = 'application/vnd.syncml+wbxml'
#Activity priority
PRIORITY = 5
...@@ -858,12 +858,13 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -858,12 +858,13 @@ class SynchronizationTool( SubscriptionSynchronization,
#LOG('sendResponse, will start sendHttpResponse, xml', DEBUG, '') #LOG('sendResponse, will start sendHttpResponse, xml', DEBUG, '')
activity = self.getActivityType(domain=domain) activity = self.getActivityType(domain=domain)
self.activate(activity=activity, self.activate(activity=activity,
tag = domain.getId()).sendHttpResponse( tag=domain.getId(),
sync_id=sync_id, priority=self.PRIORITY).sendHttpResponse(
to_url=to_url, sync_id=sync_id,
xml=xml, to_url=to_url,
domain_path=domain.getPath(), xml=xml,
content_type=content_type) domain_path=domain.getPath(),
content_type=content_type)
elif to_url.find('file://') == 0: elif to_url.find('file://') == 0:
filename = to_url[len('file:/'):] filename = to_url[len('file:/'):]
stream = file(filename,'w') stream = file(filename,'w')
...@@ -939,12 +940,13 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -939,12 +940,13 @@ class SynchronizationTool( SubscriptionSynchronization,
except socket.error, msg: except socket.error, msg:
activity = self.getActivityType(domain=domain) activity = self.getActivityType(domain=domain)
self.activate(activity=activity, self.activate(activity=activity,
tag = domain.getId()).sendHttpResponse( tag=domain.getId(),
to_url=to_url, priority=self.PRIORITY).sendHttpResponse(
sync_id=sync_id, to_url=to_url,
xml=xml, sync_id=sync_id,
domain_path=domain.getPath(), xml=xml,
content_type=content_type) domain_path=domain.getPath(),
content_type=content_type)
LOG('sendHttpResponse, socket ERROR:', INFO, msg) LOG('sendHttpResponse, socket ERROR:', INFO, msg)
LOG('sendHttpResponse, url, data', INFO, (to_url, data)) LOG('sendHttpResponse, url, data', INFO, (to_url, data))
return return
...@@ -976,7 +978,8 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -976,7 +978,8 @@ class SynchronizationTool( SubscriptionSynchronization,
newSecurityManager(None, user) newSecurityManager(None, user)
activity = self.getActivityType(domain=subscription) activity = self.getActivityType(domain=subscription)
subscription.activate(activity=activity, subscription.activate(activity=activity,
tag = subscription.getId() tag=subscription.getId(),
priority=self.PRIORITY
).SubSync(subscription.getPath()) ).SubSync(subscription.getPath())
security.declarePublic('readResponse') security.declarePublic('readResponse')
...@@ -1038,7 +1041,8 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -1038,7 +1041,8 @@ class SynchronizationTool( SubscriptionSynchronization,
#use activities to send SyncML data. #use activities to send SyncML data.
activity = self.getActivityType(domain=publication) activity = self.getActivityType(domain=publication)
publication.activate(activity=activity, publication.activate(activity=activity,
tag=publication.getId()).PubSync( tag=publication.getId(),
priority=self.PRIORITY).PubSync(
publication.getPath(), publication.getPath(),
text) text)
return ' ' return ' '
...@@ -1056,7 +1060,8 @@ class SynchronizationTool( SubscriptionSynchronization, ...@@ -1056,7 +1060,8 @@ class SynchronizationTool( SubscriptionSynchronization,
subscription_path = subscription.getPath() subscription_path = subscription.getPath()
activity = self.getActivityType(domain=subscription) activity = self.getActivityType(domain=subscription)
self.activate(activity=activity, self.activate(activity=activity,
tag=subscription.getId()).SubSync( tag=subscription.getId(),
priority=self.PRIORITY).SubSync(
subscription_path, subscription_path,
text) text)
return ' ' return ' '
......
...@@ -1453,17 +1453,18 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1453,17 +1453,18 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
PrettyPrint(remote_xml,stream=string_io) PrettyPrint(remote_xml,stream=string_io)
remote_xml = string_io.getvalue() remote_xml = string_io.getvalue()
domain.activate(activity='SQLQueue', domain.activate(activity='SQLQueue',
tag=domain.getId()).activateSyncModif( tag=domain.getId(),
priority=self.PRIORITY).activateSyncModif(
domain_relative_url = domain.getRelativeUrl(), domain_relative_url = domain.getRelativeUrl(),
remote_xml = remote_xml, remote_xml=remote_xml,
subscriber_relative_url = subscriber.getRelativeUrl(), subscriber_relative_url=subscriber.getRelativeUrl(),
cmd_id = cmd_id, cmd_id=cmd_id,
xml_confirmation = xml_confirmation, xml_confirmation=xml_confirmation,
syncml_data = '', syncml_data='',
cmd_id_before_getsyncmldata = cmd_id_before_getsyncmldata, cmd_id_before_getsyncmldata=cmd_id_before_getsyncmldata,
xml_list = xml_list, xml_list=xml_list,
has_status_list = has_status_list, has_status_list=has_status_list,
has_response = has_response ) has_response=has_response )
return {'has_response':1, 'xml':''} return {'has_response':1, 'xml':''}
else: else:
result = self.getSyncMLData(domain=domain, result = self.getSyncMLData(domain=domain,
...@@ -1494,7 +1495,8 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1494,7 +1495,8 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
sliced_gid_list = [gid_list.pop() for i in gid_list[:self.MAX_OBJECTS]] sliced_gid_list = [gid_list.pop() for i in gid_list[:self.MAX_OBJECTS]]
#Split List Processing in activities #Split List Processing in activities
self.activate(activity='SQLQueue', self.activate(activity='SQLQueue',
tag=domain.getId()).activateDeleteRemainObjectList(domain_path, tag=domain.getId(),
priority=self.PRIORITY).activateDeleteRemainObjectList(domain_path,
subscriber_path, subscriber_path,
sliced_gid_list) sliced_gid_list)
...@@ -1529,7 +1531,8 @@ class XMLSyncUtils(XMLSyncUtilsMixin): ...@@ -1529,7 +1531,8 @@ class XMLSyncUtils(XMLSyncUtilsMixin):
finished = result['finished'] finished = result['finished']
if not finished: if not finished:
domain.activate(activity='SQLQueue', domain.activate(activity='SQLQueue',
tag=domain.getId()).activateSyncModif(**kw) tag=domain.getId(),
priority=self.PRIORITY).activateSyncModif(**kw)
else: else:
xml_confirmation = result['xml_confirmation'] xml_confirmation = result['xml_confirmation']
cmd_id = result['cmd_id'] 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