Commit 4757cebe authored by Łukasz Nowak's avatar Łukasz Nowak

Update check_consistency scripts.

Reuse searchAndActivate method.

Allow to select no modules, which will result in full, unrestricted site check.
parent 2b095e8f
......@@ -50,10 +50,20 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>ap = context.newActiveProcess()\n
context.activate(tag=tag,\n
active_process=ap.getRelativeUrl()).Alarm_checkConsistency(\n
tag=tag, active_process=ap.getRelativeUrl(), fixit=fixit)\n
<value> <string>active_process = context.newActiveProcess().getRelativeUrl()\n
query_string = context.getProperty(\'catalog_query_string\', \'\')\n
# the query sould be something like "validation_state:!=deleted validation_state:!=draft portal_type:Organisation" etc\n
module_list = context.getProperty(\'module_list\') or []\n
portal = context.getPortalObject()\n
\n
kw = {\n
\'SearchableText\': query_string\n
}\n
\n
if len(module_list):\n
kw.update(parent_uid=[portal.restrictedTraverse(module).getUid() for module in module_list])\n
\n
portal.portal_catalog.searchAndActivate(method_id=\'Base_checkAlarmConsistency\', method_kw={\'fixit\': fixit, \'active_process\': active_process}, activate_kw={\'tag\':tag}, **kw)\n
</string> </value>
</item>
<item>
......
<?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>_body</string> </key>
<value> <string>query_string = context.getProperty(\'catalog_query_string\', \'\')\n
# the query sould be something like "validation_state:!=deleted validation_state:!=draft portal_type:Organisation" etc\n
module_list = context.getProperty(\'module_list\') or []\n
portal = context.getPortalObject()\n
\n
brain_list = []\n
for module in module_list:\n
module = portal.restrictedTraverse(module)\n
brain_list.extend(module.searchFolder(SearchableText=query_string, limit=None))\n
\n
path_list = []\n
for brain in brain_list:\n
if len(path_list) == 100:\n
context.activate(activity=\'SQLQueue\',\n
tag=tag,\n
active_process=active_process).Alarm_checkConsistencyOnObjectList(path_list, fixit)\n
path_list = []\n
path_list.append(brain.path)\n
\n
context.activate(activity=\'SQLQueue\',\n
tag=tag,\n
active_process=active_process).Alarm_checkConsistencyOnObjectList(path_list, fixit)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, active_process, fixit</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -57,23 +57,21 @@ constraint_message_list = []\n
traverse = context.getPortalObject().restrictedTraverse\n
property_type_validity = PropertyTypeValidity(id=\'type_check\', description=\'Type Validity Check\')\n
\n
for path in path_list:\n
document = traverse(path)\n
constraint_message_list.extend(document.checkConsistency(fixit=fixit))\n
constraint_message_list.extend(property_type_validity.checkConsistency(document, fixit=fixit))\n
constraint_message_list.extend(context.checkConsistency(fixit=fixit))\n
constraint_message_list.extend(property_type_validity.checkConsistency(context, fixit=fixit))\n
\n
if constraint_message_list:\n
return ActiveResult(severity=100,\n
constraint_message_list=constraint_message_list)\n
traverse(active_process).postResult(ActiveResult(severity=100,\n
constraint_message_list=constraint_message_list))\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>path_list, fixit</string> </value>
<value> <string>fixit, active_process</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkConsistencyOnObjectList</string> </value>
<value> <string>Base_checkAlarmConsistency</string> </value>
</item>
</dictionary>
</pickle>
......
136
\ No newline at end of file
137
\ No newline at end of file
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