Commit a9ab112f authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Eteri

DomainTool: Reduce Query usage.

Query has a higher overhead than SimpleQuery, and should be avoided
wherever possible.
Also, get rid of two unnecessary intermediate ComplexQuery levels.
There are a few remaining Query uses here, which should go away soon.
parent fc5294bc
...@@ -33,7 +33,7 @@ from Products.ERP5Type.Globals import InitializeClass, DTMLFile ...@@ -33,7 +33,7 @@ from Products.ERP5Type.Globals import InitializeClass, DTMLFile
from Products.ERP5Type import Permissions from Products.ERP5Type import Permissions
from Products.ERP5 import _dtmldir from Products.ERP5 import _dtmldir
from Products.ERP5Type.Tool.BaseTool import BaseTool from Products.ERP5Type.Tool.BaseTool import BaseTool
from Products.ZSQLCatalog.SQLCatalog import SQLQuery, Query, ComplexQuery from Products.ZSQLCatalog.SQLCatalog import SQLQuery, Query, SimpleQuery, ComplexQuery
from zLOG import LOG from zLOG import LOG
from DateTime import DateTime from DateTime import DateTime
...@@ -128,32 +128,32 @@ class DomainTool(BaseTool): ...@@ -128,32 +128,32 @@ class DomainTool(BaseTool):
value = context.getProperty(property_name) value = context.getProperty(property_name)
query = ComplexQuery( query = ComplexQuery(
Query(**{equality: None}), SimpleQuery(**{equality: None}),
Query(**{range_min: None}), SimpleQuery(**{range_min: None}),
Query(**{range_max: None}), SimpleQuery(**{range_max: None}),
logical_operator='AND') logical_operator='AND')
if value is not None: if value is not None:
query = ComplexQuery( query = ComplexQuery(
query, query,
ComplexQuery( SimpleQuery(**{equality: value}),
Query(**{equality: value}), ComplexQuery(
ComplexQuery( SimpleQuery(comparison_operator='<=', **{range_min: value}),
ComplexQuery( SimpleQuery(**{range_max: None}),
Query(**{range_min: {'query': value, 'range': 'ngt'}}), logical_operator='AND',
Query(**{range_max: None}), ),
logical_operator='AND'), ComplexQuery(
ComplexQuery( SimpleQuery(**{range_min: None}),
Query(**{range_min: None}), SimpleQuery(comparison_operator='>=', **{range_max: value}),
Query(**{range_max: {'query': value, 'range': 'min'}}), logical_operator='AND',
logical_operator='AND'), ),
ComplexQuery( ComplexQuery(
Query(**{range_min: {'query': value, 'range': 'ngt'}}), SimpleQuery(comparison_operator='<=', **{range_min: value}),
Query(**{range_max: {'query': value, 'range': 'min'}}), SimpleQuery(comparison_operator='>=', **{range_max: value}),
logical_operator='AND'), logical_operator='AND',
logical_operator='OR'), ),
logical_operator='OR'), logical_operator='OR',
logical_operator='OR') )
query_list.append(query) query_list.append(query)
......
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