Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
48ee3f8b
Commit
48ee3f8b
authored
Mar 02, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_deploy_theme: Speed up doing less catalog queries and not using Manager Proxy Roles
parent
ac048155
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
178 additions
and
10 deletions
+178
-10
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebPage_getDeploySubstitutionMappingDict.py
..._deploy_theme/WebPage_getDeploySubstitutionMappingDict.py
+12
-9
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebPage_getDeploySubstitutionMappingDict.xml
...deploy_theme/WebPage_getDeploySubstitutionMappingDict.xml
+1
-1
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebSection_getDocumentValue.py
..._skins/slapos_deploy_theme/WebSection_getDocumentValue.py
+95
-0
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebSection_getDocumentValue.xml
...skins/slapos_deploy_theme/WebSection_getDocumentValue.xml
+70
-0
No files found.
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebPage_getDeploySubstitutionMappingDict.py
View file @
48ee3f8b
mapping_dict
=
{}
map
=
{
"function_common_content"
:
"deploy-Function.Common"
,
"
base_setup_content"
:
"deploy-Base.Setup
"
,
"
slapos_install_content"
:
"deploy-Vifib.Channel
"
,
"
slapos_testing_content"
:
"deploy-Testing.Channel
"
,
"
slapos_unstable_content"
:
"deploy-Unstable.Channel
"
}
url_map
=
{
"deploy-Function.Common"
:
"function_common_content"
,
"
deploy-Base.Setup"
:
"base_setup_content
"
,
"
deploy-Vifib.Channel"
:
"slapos_install_content
"
,
"
deploy-Testing.Channel"
:
"slapos_testing_content
"
,
"
deploy-Unstable.Channel"
:
"slapos_unstable_content
"
}
portal
=
context
.
getPortalObject
()
for
m
,
reference
in
map
.
iteritems
():
doc
=
portal
.
portal_catalog
.
getResultValue
(
reference
=
reference
,
from
DateTime
import
DateTime
i
=
DateTime
()
for
doc
in
portal
.
portal_catalog
(
reference
=
url_map
.
keys
(),
portal_type
=
"Web Page"
,
validation_state
=
"published"
)
validation_state
=
"published"
)
:
mapping_dict
[
m
]
=
doc
.
getTextContent
()
mapping_dict
[
url_map
[
doc
.
getReference
()]
]
=
doc
.
getTextContent
()
context
.
log
((
DateTime
()
-
i
)
*
3600
*
24
)
return
mapping_dict
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebPage_getDeploySubstitutionMappingDict.xml
View file @
48ee3f8b
...
...
@@ -56,7 +56,7 @@
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
<string>
Anonymous
</string>
</tuple>
</value>
</item>
...
...
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebSection_getDocumentValue.py
0 → 100644
View file @
48ee3f8b
"""
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
()
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
()
validation_state
=
None
effective_date
=
None
if
validation_state
is
None
:
validation_state
=
(
'published'
,
'published_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'
),
)
# Search the catalog for all documents matching the reference
# this will only return documents which are accessible by the user
web_page_list
=
portal_catalog
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
language
=
(
language
,
''
),
sort_on
=
((
'language'
,
'descending'
),
)
+
base_sort
,
limit
=
1
,
**
kw
)
if
len
(
web_page_list
)
==
0
and
language
!=
'en'
:
# Search again with English as a fallback.
web_page_list
=
portal_catalog
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
language
=
'en'
,
sort_on
=
base_sort
,
limit
=
1
,
**
kw
)
if
len
(
web_page_list
)
==
0
:
# Search again without the language
web_page_list
=
portal_catalog
(
reference
=
name
,
effective_date
=
effective_date
,
portal_type
=
valid_portal_type_list
,
validation_state
=
validation_state
,
sort_on
=
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
master/bt5/slapos_web_deploy/SkinTemplateItem/portal_skins/slapos_deploy_theme/WebSection_getDocumentValue.xml
0 → 100644
View file @
48ee3f8b
<?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, strict_language=False, now=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebSection_getDocumentValue
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment