From a78cf6742ea2c9cd5d7fcbb3292c0cbfbd104570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com> Date: Tue, 7 Apr 2009 13:23:57 +0000 Subject: [PATCH] - 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 --- .../ERP5Administration.py | 32 ++++ .../portal_alarms/check_folder_handler.xml | 94 ++++++++++ .../ERP5Site_checkFolderHandler.xml | 164 ++++++++++++++++++ .../checkFolderHandler.xml | 31 ++++ bt5/erp5_administration/bt/revision | 2 +- bt5/erp5_administration/bt/template_path_list | 3 +- 6 files changed, 324 insertions(+), 2 deletions(-) create mode 100644 bt5/erp5_administration/PathTemplateItem/portal_alarms/check_folder_handler.xml create mode 100644 bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkFolderHandler.xml create mode 100644 bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/checkFolderHandler.xml diff --git a/bt5/erp5_administration/ExtensionTemplateItem/ERP5Administration.py b/bt5/erp5_administration/ExtensionTemplateItem/ERP5Administration.py index c9b518a620..a049c9153e 100644 --- a/bt5/erp5_administration/ExtensionTemplateItem/ERP5Administration.py +++ b/bt5/erp5_administration/ExtensionTemplateItem/ERP5Administration.py @@ -1,3 +1,4 @@ +from zLOG import LOG, INFO def dumpWorkflowChain(self): # This method outputs the workflow chain in the format that you can # easily get diff like the following: @@ -27,3 +28,34 @@ def dumpWorkflowChain(self): for chain in i['chain']: output.append('%s,%s' % (i['id'], chain)) 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 diff --git a/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_folder_handler.xml b/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_folder_handler.xml new file mode 100644 index 0000000000..9ef0df4ee4 --- /dev/null +++ b/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_folder_handler.xml @@ -0,0 +1,94 @@ +<?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> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkFolderHandler.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkFolderHandler.xml new file mode 100644 index 0000000000..28c73f2e2d --- /dev/null +++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/ERP5Site_checkFolderHandler.xml @@ -0,0 +1,164 @@ +<?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> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/checkFolderHandler.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/checkFolderHandler.xml new file mode 100644 index 0000000000..c3925c07bb --- /dev/null +++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/checkFolderHandler.xml @@ -0,0 +1,31 @@ +<?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> diff --git a/bt5/erp5_administration/bt/revision b/bt5/erp5_administration/bt/revision index 8783e30511..7c6ba0fe18 100644 --- a/bt5/erp5_administration/bt/revision +++ b/bt5/erp5_administration/bt/revision @@ -1 +1 @@ -53 \ No newline at end of file +55 \ No newline at end of file diff --git a/bt5/erp5_administration/bt/template_path_list b/bt5/erp5_administration/bt/template_path_list index d1bc89828b..1ef70fc542 100644 --- a/bt5/erp5_administration/bt/template_path_list +++ b/bt5/erp5_administration/bt/template_path_list @@ -1 +1,2 @@ -portal_alarms/check_catalog \ No newline at end of file +portal_alarms/check_catalog +portal_alarms/check_folder_handler \ No newline at end of file -- 2.30.9