diff --git a/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_skin_cache.xml b/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_skin_cache.xml new file mode 100644 index 0000000000000000000000000000000000000000..a015bccad140acd7eef27cd8c417a7dac5daefae --- /dev/null +++ b/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_skin_cache.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="Alarm" module="erp5.portal_type"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>active_sense_method_id</string> </key> + <value> <string>Alarm_checkSkinCache</string> </value> + </item> + <item> + <key> <string>alarm_notification_mode</string> </key> + <value> + <tuple> + <string>problem</string> + </tuple> + </value> + </item> + <item> + <key> <string>categories</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>description</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>enabled</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>check_skin_cache</string> </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>portal_type</string> </key> + <value> <string>Alarm</string> </value> + </item> + <item> + <key> <string>sense_method_id</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>title</string> </key> + <value> <string>check_skin_cache</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkSkinCache.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkSkinCache.xml new file mode 100644 index 0000000000000000000000000000000000000000..b2ca5f6949ed3536cad724d018432d13b38d1792 --- /dev/null +++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkSkinCache.xml @@ -0,0 +1,72 @@ +<?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>ap = context.newActiveProcess()\n +\n +context.activate(\n + active_process=ap.getRelativeUrl(),\n + tag=tag,\n + ).Alarm_checkSkinCacheActive(fixit=fixit)\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>tag, fixit=False</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Alarm_checkSkinCache</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkSkinCacheActive.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkSkinCacheActive.xml new file mode 100644 index 0000000000000000000000000000000000000000..11561fa3899792637a860ea001bfe8a80a802bb9 --- /dev/null +++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkSkinCacheActive.xml @@ -0,0 +1,124 @@ +<?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>"""\\\n +Browse portal skins to seek for non cached files.\n +\n +This Alarm returns one ActiveResult severity 100 if the file listed in this\n +script from portal_skins are not affected to a cache manager. If all files are\n +correct, it returns one ActiveResult severity 0.\n +\n +If the `fixit` parameter is considered as true, the incorrect parsed files will\n +be affected to the chosen cache manager.\n +"""\n +\n +# Cache manager to use\n +# examples: "http_cache" "anonymous_http_cache" "user_ram_cache"\n +cache_manager_id = "http_cache"\n +\n +# check all files in..\n +meta_type_checklist = "Image", "File", "Filesystem Image", "Filesystem File"\n +\n +# check all files which name endswith..\n +file_extension_checklist = ".css", ".js"\n +\n +################################################################################\n +from Products.CMFActivity.ActiveResult import ActiveResult\n +\n +incorrect_file_absolute_url_list = []\n +\n +def some(iterable, function):\n + for v in iterable:\n + if function(v): return True\n + return False\n +\n +# Browse files and folders recursively\n +def execute(skin):\n + for o in skin.objectValues():\n + # browsing files\n + oid = o.id\n + # force oid to be a string\n + if callable(oid): oid = oid()\n + if o.meta_type in meta_type_checklist or \\\n + some(file_extension_checklist, oid.endswith):\n + # this file matches the cheklists requirements\n + current_cache_manager_id = o.ZCacheable_getManagerId()\n + if current_cache_manager_id is None:\n + # the current file is not cached\n + if fixit: o.ZCacheable_setManagerId(cache_manager_id)\n + else: incorrect_file_absolute_url_list.append(o.absolute_url(relative=1))\n + elif o.meta_type == \'Folder\':\n + execute(o)\n +\n +for skin in context.portal_skins.objectValues():\n + try: execute(skin)\n + except Exception as e: incorrect_file_absolute_url_list.append(str(e))\n + \n + \n +if incorrect_file_absolute_url_list != []:\n + return ActiveResult(severity=100, detail="There is no cache set for:\\n" + "\\n".join(incorrect_file_absolute_url_list))\n + \n +return ActiveResult(severity=0, detail="OK")\n +</string> </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>fixit=False</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Alarm_checkSkinCacheActive</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_administration/bt/revision b/bt5/erp5_administration/bt/revision index 05b9b66ffd47f842c719776133f725c506144461..4e9bdff0c6937e40f3e6949b6499d11b26c0c8f3 100644 --- a/bt5/erp5_administration/bt/revision +++ b/bt5/erp5_administration/bt/revision @@ -1 +1 @@ -162 \ No newline at end of file +164 diff --git a/bt5/erp5_administration/bt/template_path_list b/bt5/erp5_administration/bt/template_path_list index 5b3215653951638e72af2a90a6de4744c730607d..b0a31272125b37152c96c23b65a69991ed29a4bf 100644 --- a/bt5/erp5_administration/bt/template_path_list +++ b/bt5/erp5_administration/bt/template_path_list @@ -4,4 +4,5 @@ portal_alarms/check_conversion_tool_availability portal_alarms/check_folder_handler portal_alarms/check_item_tracking portal_alarms/check_localizer +portal_alarms/check_skin_cache portal_alarms/check_stock \ No newline at end of file