Commit 3d7d6d5e authored by Julien Muchembled's avatar Julien Muchembled

erp5_web_shadir: index shadir entries in catalog

parent bd4b8d10
Pipeline #33075 passed with stage
in 0 seconds
<catalog_method>
<item key="sql_clear_catalog" type="int">
<value>1</value>
</item>
</catalog_method>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL Method" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z0_drop_shadir</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>SQL Method</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_uncatalog_object" type="int">
<value>1</value>
</item>
</catalog_method>
DELETE FROM shadir WHERE <dtml-sqltest uid op=eq type=int>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL Method" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>expression</string> </key>
<value> <string>python: context.isDocumentType()</string> </value>
</item>
<item>
<key> <string>expression_cache_key</string> </key>
<value>
<tuple>
<string>portal_type</string>
</tuple>
</value>
</item>
<item>
<key> <string>filtered</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z0_uncatalog_shadir</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>SQL Method</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method>
DELETE FROM
shadir
WHERE
<dtml-sqltest uid type="int" multiple>
<dtml-var sql_delimiter>
<dtml-let
a2b_hex="__import__('binascii').a2b_hex"
loads="__import__('json').loads"
row_list="[]">
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
<dtml-if "getFollowUp[loop_item]">
<dtml-let data="loads(loads(getData[loop_item])[0])">
<dtml-call expr="row_list.append((uid[loop_item], a2b_hex(data['sha512']), data.get('url')))">
</dtml-let>
</dtml-if>
</dtml-in>
<dtml-if row_list>
INSERT INTO
shadir
VALUES
<dtml-in row_list prefix="row">
(
<dtml-sqlvar expr="row_item[0]" type="int">,
<dtml-sqlvar expr="row_item[1]" type="string">,
<dtml-sqlvar expr="row_item[2]" type="string">
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
</dtml-if>
</dtml-let>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL Method" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid\n
getFollowUp\n
getData</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>expression</string> </key>
<value> <string>python: context.isDocumentType()</string> </value>
  • @jm the indexation breaks if the user includes some DocumentType that isn't a JSON:

    2024-03-01 23:59:48,295 INFO     runTestSuite: Last error message:
    2024-03-01 23:59:48,295 INFO     runTestSuite: ValueError
    2024-03-01 23:59:48,295 INFO     runTestSuite: No JSON object could be decoded
    2024-03-01 23:59:48,295 INFO     runTestSuite: Traceback (innermost last):
    2024-03-01 23:59:48,295 INFO     runTestSuite:   Module Products.CMFActivity.ActivityTool, line 1634, in invokeGroup
    2024-03-01 23:59:48,295 INFO     runTestSuite:     traverse(method_id)(expanded_object_list)
    2024-03-01 23:59:48,295 INFO     runTestSuite:   Module Products.ERP5Catalog.CatalogTool, line 982, in catalogObjectList
    2024-03-01 23:59:48,296 INFO     runTestSuite:     super(CatalogTool, self).catalogObjectList(tmp_object_list, **m.kw)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module Products.ZSQLCatalog.ZSQLCatalog, line 819, in catalogObjectList
    2024-03-01 23:59:48,296 INFO     runTestSuite:     **kw
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module Products.ZSQLCatalog.SQLCatalog, line 1275, in catalogObjectList
    2024-03-01 23:59:48,296 INFO     runTestSuite:     idxs=idxs)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module Products.ZSQLCatalog.SQLCatalog, line 1434, in _catalogObjectList
    2024-03-01 23:59:48,296 INFO     runTestSuite:     method(**kw)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module Products.ERP5Type.patches.DA, line 209, in DA__call__
    2024-03-01 23:59:48,296 INFO     runTestSuite:    - <SQL Method at /portal_6490910790707913158/portal_catalog/erp5_mysql_innodb/z_catalog_shadir_list>
    2024-03-01 23:59:48,296 INFO     runTestSuite:     query = self.template(p, **argdata)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate.DT_String, line 528, in __call__
    2024-03-01 23:59:48,296 INFO     runTestSuite:     encoding=encoding)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 146, in render_blocks
    2024-03-01 23:59:48,296 INFO     runTestSuite:     render_blocks_(blocks, rendered, md, encoding)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 247, in render_blocks_
    2024-03-01 23:59:48,296 INFO     runTestSuite:     block = block(md)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate.DT_Let, line 85, in render
    2024-03-01 23:59:48,296 INFO     runTestSuite:     return render_blocks(self.section, md, encoding=self.encoding)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 146, in render_blocks
    2024-03-01 23:59:48,296 INFO     runTestSuite:     render_blocks_(blocks, rendered, md, encoding)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 247, in render_blocks_
    2024-03-01 23:59:48,296 INFO     runTestSuite:     block = block(md)
    2024-03-01 23:59:48,296 INFO     runTestSuite:   Module DocumentTemplate.DT_In, line 765, in renderwob
    2024-03-01 23:59:48,297 INFO     runTestSuite:     append(render(section, md, encoding=self.encoding))
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 146, in render_blocks
    2024-03-01 23:59:48,297 INFO     runTestSuite:     render_blocks_(blocks, rendered, md, encoding)
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 229, in render_blocks_
    2024-03-01 23:59:48,297 INFO     runTestSuite:     render_blocks_(block, rendered, md, encoding)
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module DocumentTemplate._DocumentTemplate, line 247, in render_blocks_
    2024-03-01 23:59:48,297 INFO     runTestSuite:     block = block(md)
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module DocumentTemplate.DT_Let, line 84, in render
    2024-03-01 23:59:48,297 INFO     runTestSuite:     d[name] = expr(md)
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module DocumentTemplate.DT_Util, line 235, in eval
    2024-03-01 23:59:48,297 INFO     runTestSuite:    - __traceback_info__: loop_item
    2024-03-01 23:59:48,297 INFO     runTestSuite:     return eval(code, d)
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module <string>, line 1, in <module>
    2024-03-01 23:59:48,297 INFO     runTestSuite:     
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module json, line 339, in loads
    2024-03-01 23:59:48,297 INFO     runTestSuite:     return _default_decoder.decode(s)
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module json.decoder, line 364, in decode
    2024-03-01 23:59:48,297 INFO     runTestSuite:     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    2024-03-01 23:59:48,297 INFO     runTestSuite:   Module json.decoder, line 382, in raw_decode
    2024-03-01 23:59:48,297 INFO     runTestSuite:     raise ValueError("No JSON object could be decoded")
    2024-03-01 23:59:48,297 INFO     runTestSuite: ValueError: No JSON object could be decoded
    2024-03-01 23:59:48,297 INFO     runTestSuite: 

    The code seems to expect only shacache/shadir is on the ERP5, which should not be the case. I think it is better to check if the .getContentType() is application/json (and ensure that upload set the values properly).

  • Fixed in 8b7e104d.

Please register or sign in to reply
</item>
<item>
<key> <string>expression_cache_key</string> </key>
<value>
<tuple>
<string>portal_type</string>
</tuple>
</value>
</item>
<item>
<key> <string>filtered</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_catalog_shadir_list</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>SQL Method</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>z_catalog_shadir_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<catalog_method>
<item key="sql_clear_catalog" type="int">
<value>1</value>
</item>
</catalog_method>
CREATE TABLE `shadir` (
`uid` BIGINT UNSIGNED PRIMARY KEY,
`sha512` BINARY(64) NOT NULL,
`url` TEXT,
KEY(`sha512`)
) ENGINE=InnoDB;
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL Method" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_create_shadir</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>SQL Method</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>z_create_shadir</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<key_list>
<key>shadir</key>
</key_list>
\ No newline at end of file
erp5_mysql_innodb/z0_drop_shadir
erp5_mysql_innodb/z0_uncatalog_shadir
erp5_mysql_innodb/z_catalog_shadir_list
erp5_mysql_innodb/z_create_shadir
\ 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