Commit a78cf674 authored by Łukasz Nowak's avatar Łukasz Nowak

- add scripts and alarm to check and fix _folder_handler

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26335 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 92e13bbb
from zLOG import LOG, INFO
def dumpWorkflowChain(self): def dumpWorkflowChain(self):
# This method outputs the workflow chain in the format that you can # This method outputs the workflow chain in the format that you can
# easily get diff like the following: # easily get diff like the following:
...@@ -27,3 +28,34 @@ def dumpWorkflowChain(self): ...@@ -27,3 +28,34 @@ def dumpWorkflowChain(self):
for chain in i['chain']: for chain in i['chain']:
output.append('%s,%s' % (i['id'], chain)) output.append('%s,%s' % (i['id'], chain))
return '\n'.join(output) return '\n'.join(output)
def checkFolderHandler(self, fixit=0, **kw):
error_list = []
try:
is_btree = self.isBTree()
is_hbtree = self.isHBTree()
except AttributeError:
return error_list
message = '%s' % self.absolute_url_path()
problem = False
if not is_btree and not is_hbtree:
problem = True
message = '%s is NOT BTree NOR HBTree' % message
if fixit:
try:
result = self._fixFolderHandler()
except AttributeError:
result = False
if result:
message = '%s fixed' % message
else:
message = '%s CANNOT FIX' % message
if is_btree and is_hbtree:
problem = True
message = '%s is BTree and HBTree' % message
if fixit:
message = '%s CANNOT FIX' % message
if problem:
error_list.append(message)
LOG('checkFolderHandler', INFO, message)
return error_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="Alarm" module="Products.ERP5Type.Document.Alarm"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>ERP5Site_checkFolderHandler</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>check_folder_handler</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1230768000.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_week_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Checks folder handler</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</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>def checkTopLevel():\n
portal = context.getPortalObject()\n
for o in portal.objectValues():\n
error_list = o.checkFolderHandler(fixit=fixit)\n
if len(error_list):\n
portal.portal_activities.activate(active_process=active_process, priority=2) \\\n
.Base_makeActiveResult(title=o.absolute_url_path(), error_list=error_list)\n
\n
if \'tag\' not in kwargs:\n
kwargs[\'tag\'] = []\n
\n
kwargs.update(\n
method_id=\'checkFolderHandler\',\n
method_kw={\'fixit\': fixit},\n
)\n
\n
if context.getPortalType() == \'Alarm\':\n
active_process = context.newActiveProcess().getPath()\n
ERP5Site_checkDataWithScript = context.ERP5Site_checkDataWithScript\n
else:\n
active_process = context.portal_activities.newActiveProcess().getPath()\n
ERP5Site_checkDataWithScript = context.portal_activities.ERP5Site_checkDataWithScript\n
print \'Results will be saved to %s\' % active_process\n
\n
checkTopLevel()\n
ERP5Site_checkDataWithScript(\n
active_process=active_process,\n
*args,\n
**kwargs)\n
\n
return printed\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=0, *args, **kwargs</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>fixit</string>
<string>args</string>
<string>kwargs</string>
<string>_print_</string>
<string>_print</string>
<string>active_process</string>
<string>checkTopLevel</string>
<string>_write_</string>
<string>_getattr_</string>
<string>context</string>
<string>ERP5Site_checkDataWithScript</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_checkFolderHandler</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>checkFolderHandler</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>ERP5Administration</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>checkFolderHandler</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
53 55
\ No newline at end of file \ No newline at end of file
portal_alarms/check_catalog portal_alarms/check_catalog
portal_alarms/check_folder_handler
\ 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