Commit ce36c199 authored by Papa Tamsir Kane's avatar Papa Tamsir Kane

erp5_curation_request: Improve curation request creation alarm scalability

Do not loop over URLs. Use SearchAndActivate
parent 9b7db145
......@@ -14,9 +14,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -27,9 +25,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -40,9 +36,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......@@ -54,9 +48,7 @@
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
......
......@@ -22,9 +22,9 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>predecessor/trade_state/curation_request/submitted</string>
<string>trade_phase/curation_request/approve/legal</string>
<string>delivery_builder/portal_deliveries/decision_builder</string>
<string>predecessor/trade_state/curation_request/submitted</string>
</tuple>
</value>
</item>
......
......@@ -22,8 +22,8 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>source_decision/person_module/2</string>
<string>trade_phase/curation_request/approve/legal</string>
<string>source_decision/person_module/1</string>
</tuple>
</value>
</item>
......
from Products.ERP5Type.DateUtils import addToDate
from DateTime import DateTime
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery
from Products.ZSQLCatalog.SQLCatalog import Query
now = DateTime()
five_min_ago = addToDate(now, minute=-5)
url_query = ComplexQuery(Query(portal_type='Url'),
Query(validation_state=('draft',)),
Query(modification_date=[five_min_ago, now], range='minmax'),
logical_operator='and')
urls = context.getPortalObject().portal_catalog(query=url_query)
for url in urls:
if url.getAggregateRelatedValue() is None:
curation_request = context.curation_request_module.newContent(portal_type='Curation Request')
curation_record_line = curation_request.newContent(portal_type='Curation Request Line',
aggregate_value=url)
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type='Url',
validation_state='draft',
method_id='CurationRequest_newCurationRequestForUrl'
)
......@@ -12,6 +12,7 @@
<list>
<string>columns</string>
<string>selection_name</string>
<string>sort_columns</string>
<string>title</string>
</list>
</value>
......@@ -103,6 +104,17 @@
<key> <string>selection_name</string> </key>
<value> <string>curation_request_module_selection</string> </value>
</item>
<item>
<key> <string>sort_columns</string> </key>
<value>
<list>
<tuple>
<string>id</string>
<string>Id</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Curation Requests</string> </value>
......
#portal = context.getPortalObject()
#url = portal.restrictedTraverse(url_relative_url)
if context.getAggregateRelatedValue() is None:
curation_request = context.curation_request_module.newContent(portal_type='Curation Request')
curation_record_line = curation_request.newContent(portal_type='Curation Request Line',
aggregate_value=context)
context.submit()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CurationRequest_newCurationRequestForUrl</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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