Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
erp5
Commits
9a5a0788
Commit
9a5a0788
authored
Nov 07, 2013
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SelectionTool: Changing storage or memcached settings were not taken into effect until restart.
parent
0af872e5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
1 deletion
+97
-1
product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/memcached_plugin_interaction_workflow/scripts/MemcachedPlugin_afterEdit.xml
...nteraction_workflow/scripts/MemcachedPlugin_afterEdit.xml
+6
-0
product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/memcached_plugin_interaction_workflow/scripts/MemcachedPlugin_beforeDelete.xml
...raction_workflow/scripts/MemcachedPlugin_beforeDelete.xml
+6
-0
product/ERP5/bootstrap/erp5_core/bt/change_log
product/ERP5/bootstrap/erp5_core/bt/change_log
+3
-0
product/ERP5/bootstrap/erp5_core/bt/revision
product/ERP5/bootstrap/erp5_core/bt/revision
+1
-1
product/ERP5Form/Tool/SelectionTool.py
product/ERP5Form/Tool/SelectionTool.py
+16
-0
product/ERP5Form/tests/testSelectionTool.py
product/ERP5Form/tests/testSelectionTool.py
+65
-0
No files found.
product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/memcached_plugin_interaction_workflow/scripts/MemcachedPlugin_afterEdit.xml
View file @
9a5a0788
...
@@ -57,6 +57,12 @@ if cache_plugin_list:\n
...
@@ -57,6 +57,12 @@ if cache_plugin_list:\n
cache_tool = getToolByName(document.getPortalObject(), \'portal_caches\')\n
cache_tool = getToolByName(document.getPortalObject(), \'portal_caches\')\n
if cache_tool is not None:\n
if cache_tool is not None:\n
cache_tool.updateCache()\n
cache_tool.updateCache()\n
\n
selection_tool = document.getPortalObject()\n
if selection_tool.getStorage() == document.getRelativeUrl():\n
selection_tool.clearCachedContainer()\n
if selection_tool.getAnonymousStorage() == document.getRelativeUrl():\n
selection_tool.clearCachedContainer(is_anonymous=True)\n
</string>
</value>
</string>
</value>
</item>
</item>
<item>
<item>
...
...
product/ERP5/bootstrap/erp5_core/WorkflowTemplateItem/portal_workflow/memcached_plugin_interaction_workflow/scripts/MemcachedPlugin_beforeDelete.xml
View file @
9a5a0788
...
@@ -57,6 +57,12 @@ if cache_plugin_list:\n
...
@@ -57,6 +57,12 @@ if cache_plugin_list:\n
cache_tool = getToolByName(document.getPortalObject(), \'portal_caches\')\n
cache_tool = getToolByName(document.getPortalObject(), \'portal_caches\')\n
if cache_tool is not None:\n
if cache_tool is not None:\n
cache_tool.activate().updateCache()\n
cache_tool.activate().updateCache()\n
\n
selection_tool = document.getPortalObject()\n
if selection_tool.getStorage() == document.getRelativeUrl():\n
selection_tool.activate().clearCachedContainer()\n
if selection_tool.getAnonymousStorage() == document.getRelativeUrl():\n
selection_tool.activate().clearCachedContainer(is_anonymous=True)\n
</string>
</value>
</string>
</value>
</item>
</item>
<item>
<item>
...
...
product/ERP5/bootstrap/erp5_core/bt/change_log
View file @
9a5a0788
2013-11-07 arnaud.fontaine
* SelectionTool: Changing storage or memcached settings were not taken into effect until restart.
2013-10-04 arnaud.fontaine
2013-10-04 arnaud.fontaine
* ZODB Components: Rename common view to ComponentMixin_view (naming conventions and clash with erp5_pdm).
* ZODB Components: Rename common view to ComponentMixin_view (naming conventions and clash with erp5_pdm).
...
...
product/ERP5/bootstrap/erp5_core/bt/revision
View file @
9a5a0788
41136
41137
\ No newline at end of file
\ No newline at end of file
product/ERP5Form/Tool/SelectionTool.py
View file @
9a5a0788
...
@@ -140,6 +140,20 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -140,6 +140,20 @@ class SelectionTool( BaseTool, SimpleItem ):
storage_item_list
.
extend
([[
'/'
.
join
((
mp
.
getParentValue
().
getTitle
(),
mp
.
getTitle
(),)),
mp
.
getRelativeUrl
()]
for
mp
in
memcached_plugin_list
])
storage_item_list
.
extend
([[
'/'
.
join
((
mp
.
getParentValue
().
getTitle
(),
mp
.
getTitle
(),)),
mp
.
getRelativeUrl
()]
for
mp
in
memcached_plugin_list
])
return
storage_item_list
return
storage_item_list
security
.
declareProtected
(
ERP5Permissions
.
ModifyPortalContent
,
'updateCache'
)
def
clearCachedContainer
(
self
,
is_anonymous
=
False
):
"""
Clear Container currently being used for Selection Tool because either the
storage has changed or the its settings
"""
if
is_anonymous
:
container_id
=
'_v_anonymous_selection_container'
else
:
container_id
=
'_v_selection_container'
if
getattr
(
aq_base
(
self
),
container_id
,
None
):
delattr
(
self
,
container_id
)
security
.
declareProtected
(
ERP5Permissions
.
ManagePortal
,
'setStorage'
)
security
.
declareProtected
(
ERP5Permissions
.
ManagePortal
,
'setStorage'
)
def
setStorage
(
self
,
storage
,
anonymous_storage
=
None
,
RESPONSE
=
None
):
def
setStorage
(
self
,
storage
,
anonymous_storage
=
None
,
RESPONSE
=
None
):
"""
"""
...
@@ -147,11 +161,13 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -147,11 +161,13 @@ class SelectionTool( BaseTool, SimpleItem ):
"""
"""
if
storage
in
[
item
[
1
]
for
item
in
self
.
getStorageItemList
()]:
if
storage
in
[
item
[
1
]
for
item
in
self
.
getStorageItemList
()]:
self
.
storage
=
storage
self
.
storage
=
storage
self
.
clearCachedContainer
()
else
:
else
:
raise
ValueError
,
'Given storage type (%s) is now supported.'
%
(
storage
,)
raise
ValueError
,
'Given storage type (%s) is now supported.'
%
(
storage
,)
anonymous_storage
=
anonymous_storage
or
None
anonymous_storage
=
anonymous_storage
or
None
if
anonymous_storage
in
[
item
[
1
]
for
item
in
self
.
getStorageItemList
()]
+
[
None
]:
if
anonymous_storage
in
[
item
[
1
]
for
item
in
self
.
getStorageItemList
()]
+
[
None
]:
self
.
anonymous_storage
=
anonymous_storage
self
.
anonymous_storage
=
anonymous_storage
self
.
clearCachedContainer
(
is_anonymous
=
True
)
else
:
else
:
raise
ValueError
,
'Given storage type (%s) is now supported.'
%
(
anonymous_storage
,)
raise
ValueError
,
'Given storage type (%s) is now supported.'
%
(
anonymous_storage
,)
if
RESPONSE
is
not
None
:
if
RESPONSE
is
not
None
:
...
...
product/ERP5Form/tests/testSelectionTool.py
View file @
9a5a0788
...
@@ -386,6 +386,71 @@ class TestSelectionToolMemcachedStorage(TestSelectionTool):
...
@@ -386,6 +386,71 @@ class TestSelectionToolMemcachedStorage(TestSelectionTool):
def
testDeleteGlobalSelection
(
self
):
def
testDeleteGlobalSelection
(
self
):
pass
pass
def
testChangeSelectionToolContainer
(
self
):
"""
After changing SelectionTool container, the new one should be used
straightaway, and more specifically volatile variables should have
been reset
"""
from
Products.ERP5Form.Tool.SelectionTool
import
(
MemcachedContainer
,
PersistentMappingContainer
)
# testGetSelectionFor() already checked if the Selection can be retrieved
# from the container set in afterSetUp(), so no need to check again here
self
.
portal_selections
.
setStorage
(
'selection_data'
)
transaction
.
commit
()
self
.
assertEqual
(
getattr
(
self
.
portal_selections
,
'_v_selection_container'
,
None
),
None
)
self
.
assertEqual
(
self
.
portal_selections
.
getSelectionFor
(
'test_selection'
),
None
)
self
.
assertTrue
(
isinstance
(
getattr
(
self
.
portal_selections
,
'_v_selection_container'
,
None
),
PersistentMappingContainer
))
self
.
portal_selections
.
setStorage
(
'portal_memcached/default_memcached_plugin'
)
transaction
.
commit
()
self
.
assertEqual
(
getattr
(
self
.
portal_selections
,
'_v_selection_container'
,
None
),
None
)
self
.
assertNotEqual
(
self
.
portal_selections
.
getSelectionFor
(
'test_selection'
),
None
)
self
.
assertTrue
(
isinstance
(
getattr
(
self
.
portal_selections
,
'_v_selection_container'
,
None
),
MemcachedContainer
))
def
testChangeMemcached
(
self
):
"""
After Memcached has been changed, the new setting should be used and more
specifically container volative variables should have been reset
"""
self
.
assertNotEqual
(
self
.
portal_selections
.
getSelectionFor
(
'test_selection'
),
None
)
memcached_plugin
=
self
.
portal
.
portal_memcached
.
default_memcached_plugin
url_string_before
=
memcached_plugin
.
getUrlString
()
memcached_plugin
.
setUrlString
(
'127.0.0.1:4242'
)
transaction
.
commit
()
try
:
self
.
assertEqual
(
getattr
(
self
.
portal_selections
,
'_v_selection_container'
,
None
),
None
)
self
.
assertEqual
(
self
.
portal_selections
.
getSelectionFor
(
'test_selection'
),
None
)
self
.
assertNotEqual
(
getattr
(
self
.
portal_selections
,
'_v_selection_container'
,
None
),
None
)
finally
:
memcached_plugin
.
setUrlString
(
url_string_before
)
transaction
.
commit
()
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestSelectionTool
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestSelectionTool
))
...
...
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