Commit 28cb5471 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: No need constraint to None Creation Date

   The object will be reindexed regardless with the recent upgrades (due various factors), so this is end up as a duplicated check.
parent 72411b25
<property_sheet_list> <property_sheet_list>
<portal_type id="Catalog Tool">
<item>CatalogToolNoneCreationDateConstraint</item>
</portal_type>
<portal_type id="Certificate Authority Tool"> <portal_type id="Certificate Authority Tool">
<item>CertificateAuthorityToolConsistencyConstraint</item> <item>CertificateAuthorityToolConsistencyConstraint</item>
</portal_type> </portal_type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CatalogToolNoneCreationDateConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Script Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>constraint_type/post_upgrade</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>NoneCreationDate_existence_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Script Constraint</string> </value>
</item>
<item>
<key> <string>script_id</string> </key>
<value> <string>CatalogTool_checkNoneCreationDateConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ZSQLCatalog.SQLCatalog import Query, SimpleQuery, NegatedQuery, ComplexQuery
portal = context.getPortalObject()
error_list = []
catalog_query_kw = {
"creation_date" : None,
"select_list" : {"creation_date": None},
"query": ComplexQuery(
Query(portal_type=('Software Instance', 'Slave Instance', 'Compute Node', 'Compute Partition'),
validation_state=('validated', 'invalidated'),),
ComplexQuery(
SimpleQuery(portal_type=('Sale Order',)),
NegatedQuery(SimpleQuery(simulation_state='draft')),
logical_operator='AND'),
logical_operator='OR')
}
required_to_reindex = portal.portal_catalog.countResults(**catalog_query_kw)[0][0]
if required_to_reindex:
error_list.append('There are %s documents that require reindex due "None" creation date' % (required_to_reindex))
if fixit:
tag = 'update_none_creation_date_from_large_workflow_histories'
portal.portal_catalog.activate(tag=tag, activity='SQLQueue').searchAndActivate(
activate_kw={'tag': tag, 'priority': 6},
method_id='reindexObject',
**catalog_query_kw
)
return error_list
<?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>CatalogTool_checkNoneCreationDateConsistency</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -218,7 +218,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template): ...@@ -218,7 +218,6 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
'slapos_base/Login_notifyPasswordExpire', 'slapos_base/Login_notifyPasswordExpire',
'slapos_base/Person_applyContractInvitation', 'slapos_base/Person_applyContractInvitation',
'slapos_erp5/CertificateAuthorityTool_checkCertificateAuthorityConsistency', 'slapos_erp5/CertificateAuthorityTool_checkCertificateAuthorityConsistency',
'slapos_erp5/CatalogTool_checkNoneCreationDateConsistency',
'slapos_panel_compatibility/Base_getComputerToken', 'slapos_panel_compatibility/Base_getComputerToken',
'slapos_panel_compatibility/Person_requestComputer', 'slapos_panel_compatibility/Person_requestComputer',
'slapos_panel/AllocationSupply_invalidateComputeNodeList', 'slapos_panel/AllocationSupply_invalidateComputeNodeList',
......
Catalog Tool | CatalogToolNoneCreationDateConstraint
Certificate Authority Tool | CertificateAuthorityToolConsistencyConstraint Certificate Authority Tool | CertificateAuthorityToolConsistencyConstraint
Category Tool | CategoryToolUpgraderRegionConstraint Category Tool | CategoryToolUpgraderRegionConstraint
Contract Invitation Token | Reference Contract Invitation Token | Reference
......
CatalogToolNoneCreationDateConstraint
CategoryToolUpgraderRegionConstraint CategoryToolUpgraderRegionConstraint
CertificateAuthorityToolConsistencyConstraint CertificateAuthorityToolConsistencyConstraint
GeographicOrganisation GeographicOrganisation
......
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