Commit bee92580 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Code was moved to erp5_disaster_recovery

parent 2caa6eca
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_disaster_recovery</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
document_list = portal.portal_catalog(
limit=limit,
uid={'query': min_uid, 'range': 'nlt'},
sort_on=(('uid', 'ASC'),),
)
result_count = len(document_list)
if result_count:
if result_count == limit:
portal.portal_activities.activate(activity='SQLQueue', priority=3).ERP5Site_checkDeletedDocumentList(document_list[-1].uid, limit, packet_size)
column_list = [(x.path, x.uid) for x in document_list]
for i in xrange(0, result_count, packet_size):
portal.portal_activities.activate(activity='SQLQueue').ERP5Site_unindexDeletedDocumentList(column_list[i:i+packet_size])
<?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>min_uid, limit, packet_size</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_checkDeletedDocumentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ZSQLCatalog.SQLCatalog import Query
portal = context.getPortalObject()
document_list = portal.portal_catalog(
limit=limit,
uid={'query': min_uid, 'range': 'nlt'},
indexation_timestamp=Query(**{'indexation_timestamp': (before, now), 'range': 'minngt'}),
sort_on=(('uid', 'ASC'),),
)
result_count = len(document_list)
if result_count:
if result_count == limit:
portal.portal_activities.activate(activity='SQLQueue', priority=3).ERP5Site_checkLatestModifiedDocumentList(document_list[-1].uid, limit, packet_size, before, now)
column_list = [(x.path, x.uid) for x in document_list]
for i in xrange(0, result_count, packet_size):
portal.portal_activities.activate(activity='SQLQueue').ERP5Site_reindexOrUnindexDocumentList(column_list[i:i+packet_size])
<?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>min_uid, limit, packet_size, before, now</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_checkLatestModifiedDocumentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
now = DateTime()
before = now - int(days_before)
strfstring = '%Y-%m-%d %H:%M:%S'
portal.ERP5Site_checkLatestModifiedDocumentList(0, 1000, 100,
before.strftime(strfstring), now.strftime(strfstring))
# Force reindexation of recently created document
# This expect module to use HBTree
# The following category could be consider as "non-optimistic", but
# it is minimal compared to a whole reindex and it is safe to prevent
# Minor inconsistencies.
for module_id in portal.objectIds(("ERP5 Folder",)):
if module_id.endswith("_module"):
portal[module_id].recurseCallMethod(
'recursiveReindexObject',
max_depth=1,
min_depth=1,
max_retry=0,
activity_count=100,
min_id=before.strftime("%Y%m%d"),
)
portal.ERP5Site_checkDeletedDocumentList(0, 1000, 100)
# Whenever we trust that the catalog is consistent and more recent them the
# ZODB, it isn't required to trigger the whole reindexation of the site.
# If the Mariadb is eventually inconsitent or older them the current ZODB,
# It's required reindex the whole site.
if not optimistic:
for module_id in [
'portal_preferences',
'portal_categories',
'portal_alarms',
'portal_simulation']+portal.objectIds(("ERP5 Folder",)):
portal[module_id].recurseCallMethod(
'immediateReindexObject',
min_depth=1,
max_depth=10000,
activate_kw=dict(
group_method_id='portal_catalog/catalogObjectList',
alternate_method_id='alternateReindexObject',
group_method_cost=1,
priority=6,
),
max_retry=0,
activity_count=100,
)
return "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>optimistic=True, days_before=1</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_recoverFromRestoration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from erp5.component.module.Log import log
for path, uid in column_list:
try:
ob = context.restrictedTraverse(path)
except KeyError:
log("object not found", path)
context.portal_catalog.activate(activity='SQLQueue').uncatalog_object(uid=uid)
else:
ob.reindexObject()
<?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>column_list</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_reindexOrUnindexDocumentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from erp5.component.module.Log import log
for path, uid in column_list:
try:
_ = context.restrictedTraverse(path)
except KeyError:
log("object not found", path)
context.portal_catalog.activate(activity='SQLQueue').uncatalog_object(uid=uid)
<?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>column_list</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_unindexDeletedDocumentList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -290,11 +290,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_core/ERP5Type_getSecurityCategoryFromAggregateRelatedSoftwareInstanceInstanceTree',
'slapos_core/ERP5Type_getSecurityCategoryMapping',
'slapos_core/SlaveInstance_getSecurityCategoryFromSoftwareInstance',
'slapos_disaster_recovery/ERP5Site_checkDeletedDocumentList',
'slapos_disaster_recovery/ERP5Site_checkLatestModifiedDocumentList',
'slapos_disaster_recovery/ERP5Site_recoverFromRestoration',
'slapos_disaster_recovery/ERP5Site_reindexOrUnindexDocumentList',
'slapos_disaster_recovery/ERP5Site_unindexDeletedDocumentList',
'slapos_base/Login_getFastExpirationReferenceList',
'slapos_base/Login_isLoginBlocked',
'slapos_base/Login_isPasswordExpired',
......
......@@ -78,6 +78,7 @@ erp5_deferred_style_core
erp5_development
erp5_dhtml_style
erp5_diff
erp5_disaster_recovery
erp5_dms
erp5_fckeditor
erp5_forge
......@@ -201,7 +202,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -239,6 +239,7 @@ erp5_deferred_style_core
erp5_development
erp5_dhtml_style
erp5_diff
erp5_disaster_recovery
erp5_dms
erp5_fckeditor
erp5_forge
......@@ -252,7 +253,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -290,7 +290,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -330,7 +329,6 @@ erp5_jquery
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -372,7 +370,6 @@ erp5_km_widget_library
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : '\n'.join(common_folder_list.split('\n')[3:]),
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -408,7 +405,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -445,7 +441,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -481,7 +476,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -517,7 +511,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -554,7 +547,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -592,7 +584,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -630,7 +621,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -668,7 +658,6 @@ erp5_integration
erp5_invoicing
%(common_folder_list)s
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -707,7 +696,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -744,7 +732,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -779,7 +766,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -814,7 +800,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -849,7 +834,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -901,7 +885,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -936,7 +919,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -971,7 +953,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -1006,7 +987,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -1041,7 +1021,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......@@ -1079,7 +1058,6 @@ erp5_invoicing
%(common_folder_list)s
erp5_xhtml_style
external_method
slapos_disaster_recovery
""" % {'common_folder_list' : common_folder_list,
'common2_folder_list' : common2_folder_list,
'common3_folder_list' : common3_folder_list,
......
erp5_authentication_policy
erp5_disaster_recovery
erp5_administration
erp5_ooo_import
erp5_odt_style
......
slapos_administration
slapos_base
slapos_core
slapos_disaster_recovery
slapos_erp5
\ No newline at end of file
......@@ -292,6 +292,7 @@ class testSlapOSMixin(ERP5TypeTestCase):
'erp5_wendelin',
'erp5_development_wizard',
'erp5_smart_assistant',
'erp5_disaster_recovery',
'erp5_interaction_drop',
'slapos_mysql_innodb_catalog',
'slapos_cloud',
......
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