Commit 804dc534 authored by Ivan Tyagov's avatar Ivan Tyagov

Clean up and use proper Query.

Add comments to do.
parent 226c6458
...@@ -62,27 +62,30 @@ ...@@ -62,27 +62,30 @@
"""\n """\n
from DateTime import DateTime\n from DateTime import DateTime\n
from zExceptions import NotFound\n from zExceptions import NotFound\n
from Products.ZSQLCatalog.SQLCatalog import ComplexQuery\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
\n
\n \n
now = DateTime()\n now = DateTime()\n
request = context.REQUEST\n request = context.REQUEST\n
portal_catalog = context.portal_catalog\n portal_catalog = context.portal_catalog\n
\n \n
# keep backwards compatability\n reference = request.get(\'reference\')\n
reference = request.get(\'reference\', \\\n
request.get(\'input_stream_ref\'))\n
data_chunk = request.get(\'data_chunk\')\n data_chunk = request.get(\'data_chunk\')\n
\n \n
# XXX: add start_data and stop_date so all searches are time aware\n
default_kw = dict(validation_state = \'validated\')\n
\n
if data_chunk is not None and reference is not None:\n if data_chunk is not None and reference is not None:\n
# here we rely that fluentd will pass to us its tag which we use\n # here we rely that fluentd will pass to us its tag which we use\n
# as reference but we can extract it sometimes from sensor data\n # as reference but we can extract it sometimes from sensor data\n
# it thus depends on sensor and the fluentd topography\n # it thus depends on sensor and the fluentd topography\n
data_supply = portal_catalog.getResultValue( \\\n query=ComplexQuery(Query(portal_type = \'Data Supply\'),\n
portal_type = \'Data Supply\', \\\n Query(reference = reference),\n
reference = reference, \\\n Query(validation_state = \'validated\'),\n
**default_kw)\n # XXX: enable when final decision made if Data Supply is a\n
# Delivery or Supply\n
#Query( **{\'delivery.stop_date\':now, \'range\': \'max\'}),\n
#Query( **{\'delivery.start_date\':now, \'range\': \'min\'}),\n
operator="AND")\n
data_supply = portal_catalog.getResultValue(query=query)\n
\n \n
#context.log(data_supply)\n #context.log(data_supply)\n
# we can have multiple lines for each sensor and we filter out by reference\n # we can have multiple lines for each sensor and we filter out by reference\n
......
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