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.
- 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=now, comparison_operator='<='),
# 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]
name = context.getLayoutProperty("configuration_base_reference", "") + name
document_list = context.searchResults(
if len(document_list) == 0:
# Default returns None
document = None
# 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"?>
<record id="1" aka="AAAAAAAAAAE=">
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
<key> <string>_bind_names</string> </key>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<key> <string>_asgns</string> </key>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
<key> <string>_params</string> </key>
<value> <string>name, portal=None, language=None, validation_state=None, effective_date=None, now=None, **kw</string> </value>
<key> <string>id</string> </key>
<value> <string>StaticWebSection_getDocumentValue</string> </value>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment