Commit df7b7ef0 authored by Rafael Monnerat's avatar Rafael Monnerat 👻

erp5_administration: Drop incoherent alarm

   The alarm was replaced by a proper CodingStyle test. Fixit is incoherent since you need to edit/custom it to adjust the cache plugin for each use case.

   Rely on test result is just fine for this purpose.
parent e1fa6485
ap = context.newActiveProcess()
context.activate(
active_process=ap.getRelativeUrl(),
tag=tag,
).Alarm_checkSkinCacheActive(fixit=fixit)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>tag, fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkSkinCache</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""\
Browse portal skins to seek for non cached files.
This Alarm returns one ActiveResult severity 100 if the file listed in this
script from portal_skins are not affected to a cache manager. If all files are
correct, it returns one ActiveResult severity 0.
If the `fixit` parameter is considered as true, the incorrect parsed files will
be affected to the chosen cache manager.
"""
# Cache manager to use
# examples: "http_cache" "anonymous_http_cache" "user_ram_cache"
cache_manager_id = "http_cache"
# check all files in..
meta_type_checklist = "Image", "File", "Filesystem Image", "Filesystem File"
# check all files which name endswith..
file_extension_checklist = ".css", ".js"
################################################################################
from Products.CMFActivity.ActiveResult import ActiveResult
incorrect_file_absolute_url_list = []
def some(iterable, function):
for v in iterable:
if function(v): return True
return False
# Browse files and folders recursively
def execute(skin):
for o in skin.objectValues():
# browsing files
oid = o.id
# force oid to be a string
if callable(oid): oid = oid()
if o.meta_type in meta_type_checklist or \
some(file_extension_checklist, oid.endswith):
# this file matches the cheklists requirements
current_cache_manager_id = o.ZCacheable_getManagerId()
if current_cache_manager_id is None:
# the current file is not cached
if fixit: o.ZCacheable_setManagerId(cache_manager_id)
else: incorrect_file_absolute_url_list.append(o.absolute_url(relative=1))
elif o.meta_type == 'Folder':
execute(o)
for skin in context.portal_skins.objectValues():
execute(skin)
if incorrect_file_absolute_url_list != []:
return ActiveResult(severity=100, detail="There is no cache set for:\n" + "\n".join(incorrect_file_absolute_url_list))
return ActiveResult(severity=0, detail="OK")
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>fixit=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkSkinCacheActive</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -5,5 +5,4 @@ portal_alarms/check_folder_handler
portal_alarms/check_item_tracking
portal_alarms/check_localizer
portal_alarms/check_site_daily_modification
portal_alarms/check_skin_cache
portal_alarms/check_stock
\ 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