Commit 1a801662 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

rename SelectionTool._isAnonymous to SelectionTool.isAnonymous.

so that we can call it from restricted environment.
parent 5fcc42c2
......@@ -2466,7 +2466,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
'selection_index=%s' % self.index,
'reset:int=1'))
selection_tool = self.getObject().getPortalObject().portal_selections
if selection_tool._isAnonymous():
if selection_tool.isAnonymous():
params.append('selection_key=%s' % selection.getAnonymousSelectionKey())
if params:
url = '%s?%s' % (url, '&'.join(params))
......
......@@ -291,7 +291,7 @@ class SelectionTool( BaseTool, SimpleItem ):
if not selection_name:
return None
selection = self._getSelectionFromContainer(selection_name)
if selection is None and self._isAnonymous():
if selection is None and self.isAnonymous():
selection_key = self._getSelectionKeyFromRequest(selection_name, REQUEST)
if selection_key is not None:
selection = self.getAnonymousSelection(selection_key, selection_name)
......@@ -317,7 +317,7 @@ class SelectionTool( BaseTool, SimpleItem ):
selection_object.name))
elif self.getSelectionFor(selection_name, REQUEST=REQUEST) != selection_object:
self._setSelectionToContainer(selection_name, selection_object)
if selection_object is None and self._isAnonymous():
if selection_object is None and self.isAnonymous():
REQUEST = self._getRequest(REQUEST=REQUEST)
for key in ('%s_selection_key' % selection_name, 'selection_key'):
try:
......@@ -463,7 +463,7 @@ class SelectionTool( BaseTool, SimpleItem ):
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection:
url = selection.getListUrl()
if self._isAnonymous() and '?' in url:
if self.isAnonymous() and '?' in url:
url += '&selection_key=%s' % self._getSelectionKeyFromRequest(selection_name, REQUEST)
return url
else:
......@@ -733,7 +733,7 @@ class SelectionTool( BaseTool, SimpleItem ):
url += '?selection_index=%s&selection_name=%s' % (selection_index, selection_name)
if ignore_layout:
url += '&ignore_layout:int=1'
if self._isAnonymous():
if self.isAnonymous():
url += '&selection_key=%s' % self.getAnonymousSelectionKey(selection_name, REQUEST=REQUEST)
REQUEST.RESPONSE.redirect(url)
......@@ -1461,7 +1461,7 @@ class SelectionTool( BaseTool, SimpleItem ):
return container.getSelection(key, selection_name)
def getAnonymousSelectionKey(self, selection_name, REQUEST=None):
if not self._isAnonymous():
if not self.isAnonymous():
return ''
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is None:
......@@ -1514,11 +1514,11 @@ class SelectionTool( BaseTool, SimpleItem ):
return list(set(self._getContainer().getSelectionNameList(user_id) + \
self.getTemporarySelectionDict().keys()))
def _isAnonymous(self):
def isAnonymous(self):
return self._getUserId() == 'Anonymous User'
def _getContainer(self):
if self._isAnonymous():
if self.isAnonymous():
tv = getTransactionalVariable()
storage = tv.setdefault('_transactional_selection_container', {})
container = TransactionalCacheContainer(storage)
......
......@@ -247,7 +247,7 @@ class TestSelectionPersistence(unittest.TestCase):
# find the current user name
SelectionTool._getUserId_saved = SelectionTool._getUserId
SelectionTool._getUserId = lambda self: 'user'
SelectionTool._isAnonymous = lambda self: 0
SelectionTool.isAnonymous = lambda self: 0
self.db = ZODB.DB(ZODB.DemoStorage.DemoStorage())
self.cnx = self.db.open()
......
......@@ -30,9 +30,9 @@ import unittest
from Products.ERP5Type.tests.testFunctionalCore import \
TestZeleniumCore
# monkey patch SelectionTool._isAnonymous to render as anonymous selection.
# monkey patch SelectionTool.isAnonymous to render as anonymous selection.
from Products.ERP5Form.Tool.SelectionTool import SelectionTool
SelectionTool._isAnonymous = lambda *args, **kw:True
SelectionTool.isAnonymous = lambda *args, **kw:True
class TestAnonymousSelection(TestZeleniumCore):
foreground = 0
......
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