Commit c6d24386 authored by Thibaut Deheunynck's avatar Thibaut Deheunynck

add a new BT for erp5 administration. At this instant there is one alarm. This...

add a new BT for erp5 administration. At this instant there is one alarm. This alarm checks if the object in catalog table is present into the ZODB

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23941 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ed3fd4c
<?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>Alarm_activeCheckCatalogTable</string> </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_catalog</string> </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 Catalog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="Folder" module="OFS.Folder"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_administration</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></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>active_process = context.newActiveProcess()\n
context.Alarm_checkCatalogTable(active_process=\'/\'.join(active_process.getPhysicalPath()), tag=tag)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>fixit=0, tag=None</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>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>fixit</string>
<string>tag</string>
<string>_getattr_</string>
<string>context</string>
<string>active_process</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>0</int>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_activeCheckCatalogTable</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="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>context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_count,\n
bundle_offset=bundle_offset,\n
activity_count=1,\n
active_process=active_process,\n
tag=tag)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bundle_object_count=100, bundle_offset=0, active_process=None, tag=None</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>4</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>bundle_object_count</string>
<string>bundle_offset</string>
<string>active_process</string>
<string>tag</string>
<string>_getattr_</string>
<string>context</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>100</int>
<int>0</int>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkCatalogTable</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="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 encoding="cdata"><![CDATA[
"""\n
Check that catalog tables contain data which is coherent with actual objects.\n
Due to the number of objects to check, this function creates activites working\n
on, at maximum, bundle_object_count objects.\n
\n
bundle_object_count\n
Maximum number of objects to deal with in one transaction. \n
An activity is started after each successfull execution which\n
found bundle_object_count to work on.\n
bundle_offset\n
Offset the bundle, to allow walking along the catalog with\n
bundle_object_count increment.\n
property_override_method_id\n
Id of a method generating a property_override_dict as described below and\n
returning it.\n
property_override_dict (key: catalog column id, value: method id)\n
Defines custom methods to calculate reference column value.\n
None means that the column is not checked at all.\n
Otherwise, the function will be called on the object with no parameter\n
and must return the reference value for the column.\n
"""\n
context.log(\'ERP5Site_checkCatalogTable\', \'starting\')\n
from DateTime import DateTime\n
REFERENCE_DATETIME = DateTime()\n
MARKER = tuple()\n
bundle_object_count = 100\n
bundle_object_count=int(bundle_object_count)\n
null_value_list = (\'\', None, 0.0, 0) # Values which are all considered equal.\n
portal_catalog = context.getPortalObject().portal_catalog\n
\n
if property_override_method_id is None:\n
property_override_dict = {}\n
else:\n
property_override_dict = getattr(context, property_override_method_id)()\n
\n
if active_process is not None:\n
from Products.CMFActivity.ActiveResult import ActiveResult\n
result_list = []\n
\n
date_min = DateTime()-1\n
# First get the list of all uids\n
if catalog_uid_list is None:\n
catalog_uid_list = []\n
\n
current_catalog_uid_list = []\n
\n
if len(catalog_uid_list) > 0:\n
if len(catalog_uid_list) >= bundle_object_count:\n
current_catalog_uid_list = catalog_uid_list[0:bundle_object_count]\n
catalog_uid_list = catalog_uid_list[bundle_object_count:]\n
else:\n
current_catalog_uid_list = catalog_uid_list\n
catalog_uid_list = []\n
for brain in portal_catalog(uid=current_catalog_uid_list):\n
if brain.getObject() is None:\n
message = \'The object with uid %r (path %r) is not into the ZODB.\' % (brain[\'uid\'], brain[\'path\'])\n
result_list.append(message)\n
\n
active_context = context.getPortalObject().person_module\n
# XXX to be removed\n
if uid_min is None:\n
uid_min=0\n
fresh_data = 0\n
if len(catalog_uid_list) == 0 and get_from_catalog:\n
from DateTime import DateTime\n
date_min = DateTime() - 1\n
catalog_uid_list = [x.uid for x in context.portal_catalog(uid = {\'query\':uid_min, \'range\':\'nlt\'},\n
limit=10000, indexation_date = {\'query\':date_min, \'range\':\'min\'}, sort_on=((\'uid\',\'ascending\'),))]\n
fresh_data = 1\n
if initial_activity_count is None:\n
initial_activity_count = activity_count\n
if len(catalog_uid_list) > 0 :\n
uid_min = max(catalog_uid_list)\n
if len(catalog_uid_list) > 0:\n
if fresh_data == 1:\n
activity_count = initial_activity_count\n
activity_uid_count = len(catalog_uid_list) / activity_count\n
for activity in xrange(activity_count):\n
if activity == (activity_count - 1):\n
activity_catalog_uid_list = catalog_uid_list[activity_uid_count * activity: ]\n
else:\n
activity_catalog_uid_list = catalog_uid_list[activity_uid_count * activity: activity_uid_count * (activity+1)]\n
active_context.activate(activity=\'SQLQueue\', priority=4,\n
lonely=1,\n
round_robin_scheduling=1,\n
tag=tag).ERP5Site_checkCatalogTable(\n
bundle_object_count=bundle_object_count,\n
catalog_uid_list = activity_catalog_uid_list,\n
property_override_method_id=property_override_method_id,\n
uid_min=uid_min,\n
get_from_catalog=get_from_catalog,\n
initial_activity_count=initial_activity_count,\n
active_process=active_process,\n
tag=tag)\n
# Make sure only one node will get new data\n
get_from_catalog = 0\n
\n
if len(current_catalog_uid_list)>0:\n
now = DateTime()\n
active_result = ActiveResult()\n
summary_list = []\n
begin = current_catalog_uid_list[0]\n
end = current_catalog_uid_list[-1]\n
entry_summary = \'Entries %s..%s\' % (begin, end)\n
summary_list.append(entry_summary)\n
context.log(\'summary\', entry_summary)\n
severity = len(result_list)\n
if severity == 0:\n
summary_list.append(\'Success\')\n
else:\n
summary_list.append(\'Failed\')\n
active_result.edit(summary=\', \'.join(summary_list), severity=severity, detail=\'\\n\'.join(result_list))\n
context.log(\'active result summary =>\', active_result.getProperty(\'summary\'))\n
context.log(\'active result severity =>\', active_result.getProperty(\'severity\'))\n
active_context.activate(active_process=active_process,\n
activity=\'SQLQueue\', \n
priority=2,\n
tag=tag).ERP5Site_saveCheckStockTableResult(active_result)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>bundle_object_count=100, catalog_uid_list=None, property_override_method_id=None, active_process=None, activity_count=1, get_from_catalog=1, initial_activity_count=None, uid_min=None, tag=None, **kw</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>9</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>bundle_object_count</string>
<string>catalog_uid_list</string>
<string>property_override_method_id</string>
<string>active_process</string>
<string>activity_count</string>
<string>get_from_catalog</string>
<string>initial_activity_count</string>
<string>uid_min</string>
<string>tag</string>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>DateTime</string>
<string>REFERENCE_DATETIME</string>
<string>tuple</string>
<string>MARKER</string>
<string>int</string>
<string>None</string>
<string>null_value_list</string>
<string>portal_catalog</string>
<string>property_override_dict</string>
<string>getattr</string>
<string>Products.CMFActivity.ActiveResult</string>
<string>ActiveResult</string>
<string>result_list</string>
<string>date_min</string>
<string>current_catalog_uid_list</string>
<string>len</string>
<string>_getitem_</string>
<string>_getiter_</string>
<string>brain</string>
<string>message</string>
<string>active_context</string>
<string>fresh_data</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
<string>max</string>
<string>activity_uid_count</string>
<string>xrange</string>
<string>activity</string>
<string>activity_catalog_uid_list</string>
<string>now</string>
<string>active_result</string>
<string>summary_list</string>
<string>begin</string>
<string>end</string>
<string>entry_summary</string>
<string>severity</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<int>100</int>
<none/>
<none/>
<none/>
<int>1</int>
<int>1</int>
<none/>
<none/>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_checkCatalogTable</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="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>return result\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>result</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>result</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_saveCheckStockTableResult</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2008-10-01 thibaut
* Add an alarm. It checks which object in catalog table is into ZODB.
\ No newline at end of file
Copyright (c) 2005-2007 Nexedi SA
\ No newline at end of file
This Business Template allows to keep all administration objects in ZODB. For example alarm which checks catalog table.
\ No newline at end of file
GPL
\ No newline at end of file
None
\ No newline at end of file
3
\ No newline at end of file
None
\ No newline at end of file
portal_alarms/check_catalog
\ No newline at end of file
erp5_administration
\ No newline at end of file
erp5_administration
\ No newline at end of file
1.0
\ 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