Commit a7588514 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_officejs_appstore_base: Update to use Static Web Section, remove RJS versionning

parent 02f61c1e
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>skin_selection_name</string> </key>
<value> <string>RJSVersioning</string> </value>
<value> <string>RJS</string> </value>
</item>
<item>
<key> <string>static_language_selection</string> </key>
......@@ -435,7 +435,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>957.40967.49576.45772</string> </value>
<value> <string>958.24467.40344.6724</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -453,7 +453,7 @@
</tuple>
<state>
<tuple>
<float>1489141643.59</float>
<float>1490973425.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Section" module="erp5.portal_type"/>
<global name="Static Web Section" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -98,7 +98,7 @@
<key>
<tuple>
<int>99</int>
<string>ERP5 Web Section/development</string>
<string>ERP5 Web Section/template</string>
</tuple>
</key>
<value>
......@@ -108,22 +108,10 @@
</dictionary>
</value>
</item>
<item>
<key> <string>__translation_dict</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
......@@ -133,7 +121,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_content_security_policy</string> </value>
<value> <string>configuration_x_frame_options</string> </value>
</item>
<item>
<key> <string>type</string> </key>
......@@ -143,7 +131,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_x_frame_options</string> </value>
<value> <string>configuration_content_security_policy</string> </value>
</item>
<item>
<key> <string>type</string> </key>
......@@ -153,22 +141,10 @@
</tuple>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAc=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
......@@ -187,14 +163,6 @@
<key> <string>content_layout</string> </key>
<value> <string>WebSection_renderDefaultPageAsGadget</string> </value>
</item>
<item>
<key> <string>criterion_property</string> </key>
<value>
<tuple>
<string>validation_state</string>
</tuple>
</value>
</item>
<item>
<key> <string>custom_render_method_id</string> </key>
<value> <string>WebSection_renderDefaultPageAsGadget</string> </value>
......@@ -211,23 +179,11 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>development</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</value>
<value> <string>template</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Section</string> </value>
<value> <string>Static Web Section</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
......@@ -235,21 +191,9 @@
<none/>
</value>
</item>
<item>
<key> <string>string_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Development Version</string> </value>
<value> <string>Template Section</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
......@@ -258,7 +202,7 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAg=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -273,12 +217,6 @@
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -287,30 +225,13 @@
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>validation_state</string> </key>
<value>
<list>
<string>draft</string>
</list>
</value>
</item>
</dictionary>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -325,15 +246,7 @@
</dictionary>
</pickle>
</record>
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="8" aka="AAAAAAAAAAg=">
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -346,13 +259,13 @@
<item>
<key> <string>category_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAk=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAo=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAc=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -361,7 +274,7 @@
</dictionary>
</pickle>
</record>
<record id="9" aka="AAAAAAAAAAk=">
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......@@ -400,7 +313,7 @@
</tuple>
<state>
<tuple>
<float>1458146563.79</float>
<float>1490973336.84</float>
<string>UTC</string>
</tuple>
</state>
......@@ -416,7 +329,7 @@
</tuple>
</pickle>
</record>
<record id="10" aka="AAAAAAAAAAo=">
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......@@ -431,7 +344,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>P0</string> </value>
<value> <string>cedric.le.ninivin</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -445,7 +358,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>957.59475.44817.40669</string> </value>
<value> <string>958.24468.20075.50363</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -463,7 +376,7 @@
</tuple>
<state>
<tuple>
<float>1489153803.05</float>
<float>1490973460.32</float>
<string>UTC</string>
</tuple>
</state>
......
<registered_skin_selection>
<skin_folder_selection>
<skin_folder>erp5_web_renderjs_ui</skin_folder>
<skin_selection>RJSVersioning</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>erp5_web_versioning</skin_folder>
<skin_selection>RJSVersioning</skin_selection>
</skin_folder_selection>
</registered_skin_selection>
\ No newline at end of file
......@@ -64,7 +64,7 @@ for name in zip_reader.namelist():
temp_file = StringIO(zip_reader.read(name))
url = name[base_length:]
if url in ("index.html", "index.html"):
if url in ("index.html", "index.htm"):
publication_section = application_publication_section.landing_page.getRelativeUrl()
else:
publication_section = application_publication_section.getRelativeUrl()
......@@ -74,12 +74,11 @@ for name in zip_reader.namelist():
filename=url,
redirect_to_document=False,
user_login=user_login,
url_string=url,
reference=url,
title=url,
version=version,
publication_section_value=publication_section,
follow_up=software_release_url,
reference=url.replace("/","__"),
portal_type="File",
)
# XX Hackish
......
......@@ -10,7 +10,7 @@ try:
web_section = web_site.restrictedTraverse(version)
except KeyError:
source = portal.web_site_module.officejs_app_template
clipboard = source.manage_copyObjects(ids=["development"])
clipboard = source.manage_copyObjects(ids=["template"])
context.REQUEST.set('__cp', clipboard) # CopySupport is using this to set
# tracebility information in edit_workflow history
paste_result = web_site.manage_pasteObjects(cb_copy_data=clipboard)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_skin_layer_priority</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>business_template_skin_layer_priority</string> </key>
<value> <float>99.0</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_web_versioning</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if REQUEST is None:
REQUEST = context.REQUEST
if response is None:
response = REQUEST.RESPONSE
web_page = context
web_section = REQUEST.get("current_web_section")
if REQUEST.getHeader('If-Modified-Since', '') == web_page.getModificationDate().rfc822():
response.setStatus(304)
return ""
portal_type = web_page.getPortalType()
if portal_type in ("Web Page", "Web Script", "Web Manifest", "Web Style"):
web_content = web_page.getTextContent()
else:
if portal_type == "Web Section":
web_page = web_page.getAggregateValue()
response.setHeader('Content-Type', web_page.getContentType())
web_content = web_page.getData()
# set headers depending on type of script
if (portal_type == "Web Script"):
response.setHeader('Content-Type', 'application/javascript')
elif (portal_type == "Web Style"):
response.setHeader('Content-Type', 'text/css')
elif (portal_type == "Web Manifest"):
response.setHeader('Content-Type', 'text/cache-manifest')
elif (portal_type == "Web Page"):
if (mapping_dict is not None):
web_content = web_page.TextDocument_substituteTextContent(web_content, mapping_dict=mapping_dict)
content_security_policy = "default-src 'self' data: blob: *"
x_frame_options = "SAMEORIGIN"
if (web_section):
content_security_policy = web_section.getLayoutProperty("configuration_content_security_policy", default=content_security_policy)
x_frame_options = web_section.getLayoutProperty("configuration_x_frame_options", default=x_frame_options)
# Do not allow to put inside an iframe
if not x_frame_options == "ALLOW-FROM-ALL":
response.setHeader("X-Frame-Options", x_frame_options)
response.setHeader("X-Content-Type-Options", "nosniff")
# Only fetch code (html, js, css, image) and data from this ERP5, to prevent any data leak as the web site do not control the gadget's code
response.setHeader("Content-Security-Policy", content_security_policy)
response.setHeader('Content-Type', web_page.getContentType('text/html'))
return web_content
<?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>REQUEST=None, response=None, mapping_dict=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
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.
"""
context.log(context.REQUEST['TraversalRequestNameStack'])
stack = context.REQUEST['TraversalRequestNameStack']
if type(name) is list:
name = name[0]
url_list = [name]
while len(stack):
url_list.append(stack.pop())
context.log(name)
reference = url_list[-1]
url_string = "/".join(url_list)
#raise ValueError(url_string)
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
if portal is None: portal = context.getPortalObject()
portal_catalog = portal.portal_catalog
# The list of portal types here should be large enough to include
# all portal_types defined in the various sections so that
# href tags which point to a document by reference can still work.
valid_portal_type_list = portal.getPortalDocumentTypeList()
# Find the applicable language
if language is None:
language = portal.Localizer.get_selected_language()
if validation_state is None:
validation_state = ('released', 'released_alive', 'published', 'published_alive',
'shared', 'shared_alive', 'public', 'validated')
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'), )
# Portal Type and validation state should be handled by predicate
# By default
web_page_list = context.searchResults(
url_string=url_string,
effective_date=effective_date,
language=(language, ''),
sort_on=(('language', 'descending'), ) + base_sort,
limit=1,
**kw)
if len(web_page_list) == 0:
# Default returns None
web_page = None
else:
# Try to get the first page on the list
web_page = web_page_list[0]
web_page = web_page.getObject()
# return the web page
return web_page
<?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>WebSection_getDocumentValue</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
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.
This script returns a list of document values (ie. objects or brains)
which are considered as part of this section. It can be
a list of web pages (usual case), a list of products
(online catalog), a list of tenders (e-government), etc.
The default implementation provided here consists in
listing documents which meet the predicate defined
by the section (ex. which are part of a given publication_section)
and which are in "published" state and of a "Web Page" portal_type.
It should be noted that document selection should be implemented
as much as possible using the Domain API.
This script can be changed to meet other requirements. For example
one may want to display a list of products in a section. In this case,
this script must return a list of documents of type "Product"
with a "validated" state and in the appropriate product family.
This script is intended to be overriden by creating a new script
within the Web Section or Web Site instance. It can be also
customised per portal type within portal_skins. Customisation
thourgh local scripts is recommended to host multiple sites
on the same ERP5Site instance.
The API uses **kw so that it is possible to extend the behaviour of
the default script with advanced features (ex. group by reference,
by version, only select a specific publication state, etc.).
Here are some suggestions which can either be implemented using
SQL (group_by, order_by) or using additional python scripting
if this is compatible with data size.
SUGGESTIONS:
- Prevent showing duplicate references
- Add documents associated to this section through 'aggregate'.
- Display only the latest version and the appropriate language.
"""
from Products.ZSQLCatalog.SQLCatalog import SimpleQuery, ComplexQuery
from zExceptions import Unauthorized
try:
portal = container.getPortalObject()
kw = portal.portal_catalog.getSQLCatalog().getCannonicalArgumentDict(kw)
# First find the Web Section or Web Site we belong to
current_section = context.getWebSectionValue()
if all_versions is None:
all_versions = context.getLayoutProperty('layout_all_versions', default=False)
if all_languages is None:
all_languages = context.getLayoutProperty('layout_all_languages', default=False)
# Build the list of parameters
if not language:
language = portal.Localizer.get_selected_language()
if validation_state is None:
# XXX hardcoded validation state list.
# Use predicate or layout property instead
validation_state = ('released', 'released_alive', 'published',
'published_alive', 'shared', 'shared_alive',
'public', 'validated')
kw['validation_state'] = validation_state
if 'order_by_list' not in kw:
# XXX Do not sort by default, as it increases query time
kw['order_by_list'] = [('int_index', 'DESC'), ('reference', 'DESC')]
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',
)
kw['effective_date'] = effective_date
if not all_versions:
group_by_list = set(kw.get('group_by_list', []))
if all_languages:
kw['group_by_list'] = list(group_by_list.union(('reference', 'language')))
else:
kw['group_by_list'] = list(group_by_list.union(('reference',)))
# Extend select_dict by order_by_list and group_by_list columns.
extra_column_set = {i[0] for i in kw.get('order_by_list', ())}.union(
kw.get('group_by_list', ()))
kw.setdefault('select_dict', {}).update(
(x.replace('.', '_') + '__ext__', x)
for x in extra_column_set if not x.endswith('__score__'))
#raise ValueError("%s" % current_section.WebSection_zGetDocumentValueList(language=language,
# all_languages=all_languages,
# src__=1,
# kw=kw))
return current_section.WebSection_zGetDocumentValueList(language=language,
all_languages=all_languages,
src__=src__,
kw=kw)
else:
if not all_languages:
kw['language'] = language
return current_section.searchResults(src__=src__, **kw)
except Unauthorized:
return []
<?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>language=None, validation_state=None, all_languages=None, all_versions=None, effective_date=None, now=None, src__=0, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getDocumentValueListBase</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
erp5_web_renderjs_ui | RJSVersioning
erp5_web_versioning | RJSVersioning
\ No newline at end of file
erp5_officejs_appstore_base
erp5_web_versioning
\ No newline at end of file
erp5_officejs_appstore_base
\ 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