Commit 73c99612 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Titouan Soulard

erp5_api_style: Move JIO API revision to depend on the web section

parent 69327762
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jio_api_revision_configuration</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>3.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>JIO API Revisions</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/JIOWebSection_viewJIOAPIRevisionConfiguration</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -38,22 +38,28 @@ class JIOAPIRevisionMixin: ...@@ -38,22 +38,28 @@ class JIOAPIRevisionMixin:
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getJIOAPIRevision') 'getJIOAPIRevision')
def getJIOAPIRevision(self): def getJIOAPIRevision(self, web_section):
""" """
Return Object Revision Return Object Revision
""" """
return self._getJIOAPIRevisionTuple()[0] return self._getJIOAPIRevisionTuple(web_section)[0]
def _unindexJIOAPIRevision(self): def _unindexJIOAPIRevision(self, web_section):
try: try:
self.Base_zUnindexFromjIOAPIRevisionTable(uid=self.getUid()) self.Base_zUnindexFromjIOAPIRevisionTable(
uid=self.getUid(),
web_section=web_section
)
except ProgrammingError: except ProgrammingError:
# jio_api_revision table is not created # jio_api_revision table is not created
pass pass
def _getJIOAPIRevisionTuple(self): def _getJIOAPIRevisionTuple(self, web_section):
try: try:
result = self.Base_zGetFromIOAPIRevisionTable(uid=self.getUid()) result = self.Base_zGetFromIOAPIRevisionTable(
uid=self.getUid(),
web_section=web_section,
)
except ProgrammingError: except ProgrammingError:
# jio_api_revision table is not created # jio_api_revision table is not created
return None, None, None return None, None, None
...@@ -61,54 +67,65 @@ class JIOAPIRevisionMixin: ...@@ -61,54 +67,65 @@ class JIOAPIRevisionMixin:
return result[0].revision, result[0].hash, result[0].indexation_timestamp return result[0].revision, result[0].hash, result[0].indexation_timestamp
return None, None, None return None, None, None
def _calculateHash(self): def _calculateHash(self, web_section, hash_method):
hash_method = self.getTypeBasedMethod("calculatejIOAPIRevisionHash")
if not hash_method: if not hash_method:
return None return None
return hash_method() hash_method = getattr(self, hash_method)
return hash_method(web_section=web_section)
security.declareProtected(Permissions.ManagePortal, 'updateJIOAPIRevision') security.declareProtected(Permissions.ManagePortal, 'updateJIOAPIRevision')
def updateJIOAPIRevision(self): def updateJIOAPIRevision(self, web_section_url, hash_method):
""" """
Update jIO API Revision Update jIO API Revision
""" """
calculated_hash = self._calculateHash(web_section_url, hash_method)
if not calculated_hash:
self._unindexJIOAPIRevision(web_section_url)
return
indexation_timestamp = int(DateTime(self.getPortalObject().portal_catalog( indexation_timestamp = int(DateTime(self.getPortalObject().portal_catalog(
uid=self.getUid(), select_list=('indexation_timestamp',) uid=self.getUid(), select_list=('indexation_timestamp',)
)[0].indexation_timestamp)) )[0].indexation_timestamp))
calculated_hash = self._calculateHash()
if not calculated_hash:
self._unindexJIOAPIRevision()
return
stored_hash = None stored_hash = None
_, stored_hash, stored_timestamp = self._getJIOAPIRevisionTuple() _, stored_hash, stored_timestamp = self._getJIOAPIRevisionTuple(web_section_url)
stored_timestamp = int(DateTime(stored_timestamp)) stored_timestamp = int(DateTime(stored_timestamp))
if stored_hash == calculated_hash: if stored_hash == calculated_hash:
if stored_timestamp != indexation_timestamp: if stored_timestamp != indexation_timestamp:
self.Base_zUpdateTimeStampjIOAPIRevisionTable( self.Base_zUpdateTimeStampjIOAPIRevisionTable(
uid=self.getUid(), uid=self.getUid(),
indexation_timestamp=indexation_timestamp, indexation_timestamp=indexation_timestamp,
web_section=web_section_url
) )
return return
new_revision = self.Base_getNewjIOAPIRevision() new_revision = self.Base_getNewjIOAPIRevision(web_section_url)
self.Base_zUpdatejIOAPIRevisionTable( self.Base_zUpdatejIOAPIRevisionTable(
uid=self.getUid(), uid=self.getUid(),
revision=new_revision, revision=new_revision,
hash=calculated_hash, hash=calculated_hash,
indexation_timestamp=indexation_timestamp, indexation_timestamp=indexation_timestamp,
web_section=web_section_url
) )
return return
def _getHashMethodFromWebSection(self, web_section_url):
hash_method_list = [[
y.strip() for y in x.split('|')] for x in \
self.getPortalObject().restrictedTraverse(web_section_url).getRevisionHashCalculationMethodPerTypeList()]
hash_method_dict = {x[0]: x[1] for x in hash_method_list}
return hash_method_dict.get(self.getPortalType(), None)
security.declareProtected(Permissions.ManagePortal, 'markUnmatchingJIOAPIrevisionHash') security.declareProtected(Permissions.ManagePortal, 'markUnmatchingJIOAPIrevisionHash')
def markUnmatchingJIOAPIrevisionHash(self): def markUnmatchingJIOAPIrevisionHash(self, web_section_url, hash_method=None):
""" """
Check if the calculated hash match the stored one. Check if the calculated hash match the stored one.
If not set jio_api_revision timestamp to 0 to triger reprocessing by alarm If not set jio_api_revision timestamp to 0 to triger reprocessing by alarm
""" """
calculated_hash = self._calculateHash() if not hash_method:
_, stored_hash, _ = self._getJIOAPIRevisionTuple() hash_method = self._getHashMethodFromWebSection(web_section_url)
calculated_hash = self._calculateHash(web_section_url, hash_method)
_, stored_hash, _ = self._getJIOAPIRevisionTuple(web_section_url)
if calculated_hash != stored_hash: if calculated_hash != stored_hash:
# Marking jIO API revision timestamp to zero will trigger reprocessing # Marking jIO API revision timestamp to zero will trigger reprocessing
self.Base_zUpdateTimeStampjIOAPIRevisionTable( self.Base_zUpdateTimeStampjIOAPIRevisionTable(
...@@ -119,13 +136,15 @@ class JIOAPIRevisionMixin: ...@@ -119,13 +136,15 @@ class JIOAPIRevisionMixin:
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'checkJIOAPIRevisionConstraint') 'checkJIOAPIRevisionConstraint')
def checkJIOAPIRevisionConstraint(self, **kw): def checkJIOAPIRevisionConstraint(self, web_section_url, hash_method=None):
""" """
Check is calculated Hash equals to the stored one Check is calculated Hash equals to the stored one
Fixing is not offered as it needs to be centralised to avoid missing a new revision for an object Fixing is not offered as it needs to be centralised to avoid missing a new revision for an object
""" """
calculated_hash = self._calculateHash() if not hash_method:
_, stored_hash, _ = self._getJIOAPIRevisionTuple() hash_method = self._getHashMethodFromWebSection(web_section_url)
calculated_hash = self._calculateHash(web_section_url, hash_method)
_, stored_hash, _ = self._getJIOAPIRevisionTuple(web_section_url)
if calculated_hash != stored_hash: if calculated_hash != stored_hash:
return [self.Base_translateString( return [self.Base_translateString(
"Stored Hash ${stored_hash} difer from calculated hash ${calculated_hash}", "Stored Hash ${stored_hash} difer from calculated hash ${calculated_hash}",
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<item>TextDocument</item> <item>TextDocument</item>
</portal_type> </portal_type>
<portal_type id="jIO Web Section"> <portal_type id="jIO Web Section">
<item>JIOAPIRevisionConfiguration</item>
<item>SortIndex</item> <item>SortIndex</item>
<item>WebSectionUpgradeConstraint</item> <item>WebSectionUpgradeConstraint</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>JIOAPIRevisionConfiguration</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="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>revision_hash_calculation_method_per_type_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: ()</string> </value>
</item>
<item>
<key> <string>read_permission</string> </key>
<value> <string>Modify portal content</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>select_missing_revision_object_list_method_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>read_permission</string> </key>
<value> <string>Modify portal content</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>select_updatable_revision_object_list_method_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>read_permission</string> </key>
<value> <string>Modify portal content</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if not context.Base_zCheckjIOAPIRevisionTableExists(): if not context.Base_zCheckjIOAPIRevisionTableExists():
context.Base_zCreatejIOAPIRevisionTable() context.Base_zCreatejIOAPIRevisionTable()
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery
context.getPortalObject().portal_catalog.searchAndActivate( context.getPortalObject().portal_catalog.searchAndActivate(
method_id='markUnmatchingJIOAPIrevisionHash', method_id='JIOWebSection_checkAndFixUnmatchingJIOAPIRevisionHash',
method_kw={'tag': tag},
activate_kw={'tag':tag, 'priority': 8}, activate_kw={'tag':tag, 'priority': 8},
query=SimpleQuery(comparison_operator="!=", **{"jio_api_revision.revision": None}), portal_type="jIO Web Section",
validation_state="!=expired",
) )
......
...@@ -3,14 +3,11 @@ if not context.Base_zCheckjIOAPIRevisionTableExists(): ...@@ -3,14 +3,11 @@ if not context.Base_zCheckjIOAPIRevisionTableExists():
portal = context.getPortalObject() portal = context.getPortalObject()
# Get the list of objects that should have a jio api revision but do not have portal.portal_catalog.searchAndActivate(
potentially_missing_object_list = portal.Base_zSelectMissingJIOAPIRevisionObjectList() method_id="JIOWebSection_updateJIOAPIRevision",
for element in potentially_missing_object_list: portal_type="jIO Web Section",
portal.unrestrictedTraverse(element.relative_url).updateJIOAPIRevision() validation_state="!=expired",
activate_kw={'tag':tag},
# Get the list of objects that have a jio api revision and where indexation timestamp has changed since last check )
updatable_object_list = context.Base_zSelectUpdatableJIOAPIRevisionObjectList()
for element in updatable_object_list:
portal.unrestrictedTraverse(element.relative_url).updateJIOAPIRevision()
context.activate(after_tag=tag).getId() context.activate(after_tag=tag).getId()
return context.getPortalObject().portal_ids.generateNewId(id_group=repr(('revision', "jio_api_reference")), default=1) return context.getPortalObject().portal_ids.generateNewId(id_group=repr(('revision', "jio_api_reference", web_section_url)), default=1)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>web_section_url</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
CREATE TABLE `jio_api_revision` ( CREATE TABLE `jio_api_revision` (
`uid` BIGINT UNSIGNED NOT NULL, `uid` BIGINT UNSIGNED NOT NULL,
`revision` varchar(255) NOT NULL UNIQUE, `revision` varchar(255) NOT NULL,
`hash` varchar(255), `hash` varchar(255),
`indexation_timestamp` TIMESTAMP(6), `indexation_timestamp` TIMESTAMP(6),
PRIMARY KEY (`uid`) `web_section` varchar(255) NOT NULL,
PRIMARY KEY (`uid`, `web_section`),
CONSTRAINT UC_Revision UNIQUE (`revision`, `web_section`)
) ENGINE=InnoDB ) ENGINE=InnoDB
\ No newline at end of file
...@@ -3,4 +3,4 @@ SELECT ...@@ -3,4 +3,4 @@ SELECT
FROM FROM
jio_api_revision jio_api_revision
WHERE WHERE
uid=<dtml-sqlvar expr="uid" type="int"> uid=<dtml-sqlvar expr="uid" type="int"> AND web_section=<dtml-sqlvar expr="web_section" type="string">
...@@ -6,9 +6,71 @@ ...@@ -6,9 +6,71 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_col</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>revision</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>hash</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>9</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>indexation_timestamp</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>d</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>26</int> </value>
</item>
</dictionary>
</list>
</value>
</item>
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string encoding="base64">dWlkCg==</string> </value> <value> <string>uid\n
web_section</string> </value>
</item> </item>
<item> <item>
<key> <string>connection_id</string> </key> <key> <string>connection_id</string> </key>
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>web_section</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
select catalog.uid, catalog.relative_url from catalog join jio_api_revision on CAST(catalog.indexation_timestamp AS INT) != CAST(jio_api_revision.indexation_timestamp AS INT) AND catalog.uid = jio_api_revision.uid select
catalog.uid,
catalog.relative_url,
catalog.portal_type
from
catalog
join
jio_api_revision on CAST(catalog.indexation_timestamp AS INT) != CAST(jio_api_revision.indexation_timestamp AS INT) AND catalog.uid = jio_api_revision.uid
where
jio_api_revision.web_section=<dtml-sqlvar expr="web_section" type="string">
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</item> </item>
<item> <item>
<key> <string>width</string> </key> <key> <string>width</string> </key>
<value> <int>0</int> </value> <value> <int>6</int> </value>
</item> </item>
</dictionary> </dictionary>
<dictionary> <dictionary>
...@@ -43,7 +43,25 @@ ...@@ -43,7 +43,25 @@
</item> </item>
<item> <item>
<key> <string>width</string> </key> <key> <string>width</string> </key>
<value> <int>0</int> </value> <value> <int>39</int> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>name</string> </key>
<value> <string>portal_type</string> </value>
</item>
<item>
<key> <string>null</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>t</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>17</int> </value>
</item> </item>
</dictionary> </dictionary>
</list> </list>
...@@ -51,7 +69,7 @@ ...@@ -51,7 +69,7 @@
</item> </item>
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string></string> </value> <value> <string>web_section</string> </value>
</item> </item>
<item> <item>
<key> <string>connection_id</string> </key> <key> <string>connection_id</string> </key>
......
DELETE FROM jio_api_revision WHERE <dtml-sqltest uid op=eq type=int> DELETE FROM jio_api_revision WHERE <dtml-sqltest uid op=eq type=int> AND <dtml-sqltest web_section op=eq type=string>
...@@ -6,9 +6,16 @@ ...@@ -6,9 +6,16 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_col</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string>uid</string> </value> <value> <string>uid\n
web_section</string> </value>
</item> </item>
<item> <item>
<key> <string>connection_id</string> </key> <key> <string>connection_id</string> </key>
......
DELETE FROM DELETE FROM
jio_api_revision jio_api_revision
WHERE WHERE
uid=<dtml-sqlvar expr="uid" type="int"> uid=<dtml-sqlvar expr="uid" type="int"> AND web_section=<dtml-sqlvar expr="web_section" type="string">
; ;
<dtml-var "'\0'"> <dtml-var "'\0'">
...@@ -14,6 +14,7 @@ VALUES ...@@ -14,6 +14,7 @@ VALUES
<dtml-sqlvar expr="uid" type="int">, <dtml-sqlvar expr="uid" type="int">,
<dtml-sqlvar expr="revision" type="string" optional>, <dtml-sqlvar expr="revision" type="string" optional>,
<dtml-sqlvar expr="hash" type="string" optional>, <dtml-sqlvar expr="hash" type="string" optional>,
<dtml-sqlvar expr="indexation_timestamp" type="datetime" optional> <dtml-sqlvar expr="indexation_timestamp" type="datetime" optional>,
<dtml-sqlvar expr="web_section" type="string" optional>
) )
...@@ -6,12 +6,19 @@ ...@@ -6,12 +6,19 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_col</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>arguments_src</string> </key> <key> <string>arguments_src</string> </key>
<value> <string>uid\n <value> <string>uid\n
revision\n revision\n
hash\n hash\n
indexation_timestamp</string> </value> indexation_timestamp\n
web_section</string> </value>
</item> </item>
<item> <item>
<key> <string>connection_id</string> </key> <key> <string>connection_id</string> </key>
......
context.getPortalObject().portal_catalog.searchAndActivate(
method_id='markUnmatchingJIOAPIrevisionHash',
method_kw={"web_section_url": context.getRelativeUrl()},
activate_kw={'tag':tag, 'priority': 8},
**{"jio_api_revision.web_section": context.getRelativeUrl()}
)
<?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>_params</string> </key>
<value> <string>tag</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>JIOWebSection_checkAndFixUnmatchingJIOAPIRevisionHash</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
select_missing_method = context.getSelectMissingRevisionObjectListMethod()
select_updatable_method = context.getSelectUpdatableRevisionObjectListMethod()
hash_method_list = [[y.strip() for y in x.split('|')] for x in \
context.getRevisionHashCalculationMethodPerTypeList()]
hash_method_dict = {x[0]: x[1] for x in hash_method_list}
if not select_missing_method or not select_updatable_method or not hash_method_dict:
# Revisions are not configured
return
portal = context.getPortalObject()
web_section_relative_url = context.getRelativeUrl()
# Get the list of objects that should have a jio api revision but do not have
potentially_missing_object_list = getattr(portal, select_missing_method)(web_section=web_section_relative_url)
# Get the list of objects that have a jio api revision and where indexation timestamp has changed since last check
updatable_object_list = getattr(portal, select_updatable_method)(web_section=web_section_relative_url)
for result_list in (updatable_object_list, potentially_missing_object_list):
for element in result_list:
portal.restrictedTraverse(element.relative_url).updateJIOAPIRevision(
web_section_relative_url,
hash_method_dict.get(element.portal_type, None)
)
<?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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>JIOWebSection_updateJIOAPIRevision</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list>
<string>my_revision_hash_calculation_method_per_type_list</string>
</list>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_select_missing_revision_object_list_method</string>
<string>my_select_updatable_revision_object_list_method</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>JIOWebSection_viewJIOAPIRevisionConfiguration</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>JIOWebSection_viewJIOAPIRevisionConfiguration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>ERP5 Form</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>JIO API Revision Configuration</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>height</string>
<string>title</string>
<string>width</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_revision_hash_calculation_method_per_type_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_lines_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewWebFieldLibrary</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>10</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Revision Hash Calculation Method per Type</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>100</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_select_missing_revision_object_list_method</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewWebFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Select Missing Revision Method</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_select_updatable_revision_object_list_method</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewWebFieldLibrary</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Select Updatable Revision Method</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
mode = mode or context.REQUEST.form.get("mode", "get") mode = mode or context.REQUEST.form.get("mode", "get")
text_content = text_content or context.REQUEST.form.get("text_content", "") text_content = text_content or context.REQUEST.form.get("text_content", "")
document_id = document_id or context.REQUEST.form.get("document_id", "") document_id = document_id or context.REQUEST.form.get("document_id", "")
web_section_value = context.getWebSectionValue()
if web_section_value:
context.REQUEST.set("web_section_relative_url", web_section_value.getRelativeUrl())
import json import json
portal = context.getPortalObject() portal = context.getPortalObject()
......
Error Record Module | view Error Record Module | view
Error Record | view Error Record | view
jIO Web Section | jio_api_revision_configuration
jIO Web Section | layout_configuration jIO Web Section | layout_configuration
jIO Web Section | local_permission jIO Web Section | local_permission
jIO Web Section | predicate jIO Web Section | predicate
......
Error Record | TextDocument Error Record | TextDocument
jIO Web Section | JIOAPIRevisionConfiguration
jIO Web Section | SortIndex jIO Web Section | SortIndex
jIO Web Section | WebSectionUpgradeConstraint jIO Web Section | WebSectionUpgradeConstraint
\ No newline at end of file
JIOAPIRevisionConstraint JIOAPIRevisionConstraint
\ No newline at end of file JIOAPIRevisionConfiguration
\ 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