Commit 3995af49 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

officejs_base: Add dedicated Static get Document Value to include base reference

parent 842e04c3
"""
This script is part of ERP5 Web
ERP5 Web is a business template of ERP5 which provides a way
to create web sites which can display selected
ERP5 contents through multiple custom web layouts.
The default implementation searches for
documents which are in the user language if any
and which reference is equal to the name parameter.
Other implementations are possible: ex. display the last
version in the closest language rather than
the latest version in the user language.
NOTE:
- the portal parameter was introduced to
fix acquisition issues within the _aq_dynamic
lookup from WebSection class.
"""
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
if portal is None: portal = context.getPortalObject()
if effective_date is None:
if now is None:
now = DateTime()
effective_date = ComplexQuery(
SimpleQuery(effective_date=None),
SimpleQuery(effective_date=now, comparison_operator='<='),
logical_operator='or',
)
# Note: In sorts, NULL is considered lesser than non-NULL. So in descending
# sort, NULLs will be listed after non-NULLs, which is perfect for
# effective_date, which defines the date at which content becomes effective.
# None (NULL) effective date hence means "effective since infinite in te past".
base_sort = (('effective_date', 'descending'), )
# A list is provided for the default page, in this case no need to add
# the current id
if isinstance(name, list):
name = name[0]
else:
name = context.getLayoutProperty("configuration_base_reference", "") + name
document_list = context.searchResults(
reference=name,
effective_date=effective_date,
sort_on=base_sort,
limit=1,
**kw)
if len(document_list) == 0:
# Default returns None
document = None
else:
# Try to get the first page on the list
document = document_list[0]
document = document.getObject()
# return the web page
return document
<?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>name, portal=None, language=None, validation_state=None, effective_date=None, now=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>StaticWebSection_getDocumentValue</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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