Commit fe773036 authored by Vincent Pelletier's avatar Vincent Pelletier

use getIdOrUserName() instead of __str__().

parent e8ae14a5
...@@ -89,7 +89,7 @@ item_list = getItemList( category=category, ...@@ -89,7 +89,7 @@ item_list = getItemList( category=category,
portal_path=context.getPortalObject().getPhysicalPath(), portal_path=context.getPortalObject().getPhysicalPath(),
mirror=mirror, mirror=mirror,
omit_filter=omit_filter, # XXX possible optim: only one cache if omit_filter omit_filter=omit_filter, # XXX possible optim: only one cache if omit_filter
user_name=str(getSecurityManager().getUser()), user_name=getSecurityManager().getUser().getIdOrUserName(),
simulation_state=simulation_state) simulation_state=simulation_state)
# make sure that the current value is included in this list, this is # make sure that the current value is included in this list, this is
......
...@@ -92,7 +92,7 @@ for person in context.person_module.objectValues(): ...@@ -92,7 +92,7 @@ for person in context.person_module.objectValues():
knowledge_pad.visible() knowledge_pad.visible()
current_user = context.portal_membership.getAuthenticatedMember() current_user = context.portal_membership.getAuthenticatedMember()
knowledge_pad.manage_setLocalRoles(userid=user_name, roles=['Owner']) knowledge_pad.manage_setLocalRoles(userid=user_name, roles=['Owner'])
knowledge_pad.manage_delLocalRoles([str(current_user)]) knowledge_pad.manage_delLocalRoles([current_user.getIdOrUserName()])
knowledge_pad.reindexObject() knowledge_pad.reindexObject()
knowledge_box = knowledge_pad.newContent(portal_type='Knowledge Box', knowledge_box = knowledge_pad.newContent(portal_type='Knowledge Box',
......
...@@ -335,7 +335,7 @@ class TestEGovMixin(SecurityTestCase): ...@@ -335,7 +335,7 @@ class TestEGovMixin(SecurityTestCase):
''' '''
# save previous user # save previous user
previous_user = str(getSecurityManager().getUser()) previous_user = getSecurityManager().getUser().getIdOrUseName()
self.loginAsUser(login) self.loginAsUser(login)
worklist_dict = self.portal.getPortalTypeWorklistDictForWorkflow(\ worklist_dict = self.portal.getPortalTypeWorklistDictForWorkflow(\
......
...@@ -56,7 +56,7 @@ knowledge_pad.visible() ...@@ -56,7 +56,7 @@ knowledge_pad.visible()
if owner is not None: if owner is not None:
current_user = context.portal_membership.getAuthenticatedMember() current_user = context.portal_membership.getAuthenticatedMember()
knowledge_pad.manage_setLocalRoles(userid=owner, roles=['Owner']) knowledge_pad.manage_setLocalRoles(userid=owner, roles=['Owner'])
knowledge_pad.manage_delLocalRoles([str(current_user)]) knowledge_pad.manage_delLocalRoles([current_user.getIdOrUserName()])
knowledge_pad.reindexObject() knowledge_pad.reindexObject()
# set default gadgets # set default gadgets
......
...@@ -182,7 +182,7 @@ class Message(BaseMessage): ...@@ -182,7 +182,7 @@ class Message(BaseMessage):
# was generated. # was generated.
# Strip last stack entry, since it will always be the same. # Strip last stack entry, since it will always be the same.
self.call_traceback = ''.join(format_list(extract_stack()[:-1])) self.call_traceback = ''.join(format_list(extract_stack()[:-1]))
self.user_name = str(_getAuthenticatedUser(self)) self.user_name = _getAuthenticatedUser(self).getIdOrUserName()
# Store REQUEST Info # Store REQUEST Info
self.request_info = {} self.request_info = {}
if request is not None: if request is not None:
......
...@@ -480,7 +480,7 @@ class ContributionTool(BaseTool): ...@@ -480,7 +480,7 @@ class ContributionTool(BaseTool):
sm = getSecurityManager() sm = getSecurityManager()
user = sm.getUser() user = sm.getUser()
object_list = self.portal_catalog(portal_type=self.getPortalMyDocumentTypeList(), object_list = self.portal_catalog(portal_type=self.getPortalMyDocumentTypeList(),
owner=str(user)) owner=user.getIdOrUserName())
def wrapper(o_list): def wrapper(o_list):
for o in o_list: for o in o_list:
......
...@@ -26,7 +26,7 @@ def getPreferredSectionItemList(portal_type, validation_state): ...@@ -26,7 +26,7 @@ def getPreferredSectionItemList(portal_type, validation_state):
getPreferredSectionItemList = CachingMethod(getPreferredSectionItemList, getPreferredSectionItemList = CachingMethod(getPreferredSectionItemList,
'%s.%s' % (script.getId(), '%s.%s' % (script.getId(),
getSecurityManager().getUser()), getSecurityManager().getUser().getIdOrUserName()),
cache_factory='erp5_ui_short') cache_factory='erp5_ui_short')
section_item_list = getPreferredSectionItemList(portal_type, validation_state) section_item_list = getPreferredSectionItemList(portal_type, validation_state)
......
...@@ -66,7 +66,7 @@ class DiscoverableMixin(CachedConvertableMixin): ...@@ -66,7 +66,7 @@ class DiscoverableMixin(CachedConvertableMixin):
returns properties which should be set on the document returns properties which should be set on the document
""" """
if user_login is None: if user_login is None:
user_login = str(getSecurityManager().getUser()) user_login = getSecurityManager().getUser().getIdOrUserName()
method = self._getTypeBasedMethod('getPropertyDictFromUserLogin', method = self._getTypeBasedMethod('getPropertyDictFromUserLogin',
fallback_script_id='Document_getPropertyDictFromUserLogin') fallback_script_id='Document_getPropertyDictFromUserLogin')
if method is not None: if method is not None:
......
...@@ -410,7 +410,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -410,7 +410,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self._assertUserExists('homie', 'secret') self._assertUserExists('homie', 'secret')
self.login('homie') self.login('homie')
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
self.assertEqual(str(getSecurityManager().getUser()), 'homie') self.assertEqual(getSecurityManager().getUser().getIdOrUserName(), 'homie')
def stepCreateCredentialUpdate(self, sequence=None, sequence_list=None, **kw): def stepCreateCredentialUpdate(self, sequence=None, sequence_list=None, **kw):
''' '''
...@@ -597,7 +597,7 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -597,7 +597,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self._assertUserExists('barney', 'secret') self._assertUserExists('barney', 'secret')
self.login('barney') self.login('barney')
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
self.assertEqual(str(getSecurityManager().getUser()), 'barney') self.assertEqual(getSecurityManager().getUser().getIdOrUserName(), 'barney')
self.login() self.login()
# create a credential recovery # create a credential recovery
......
...@@ -321,11 +321,11 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -321,11 +321,11 @@ Hé Hé Hé!""", page.asText().strip())
# check if user account is 'loggable' # check if user account is 'loggable'
uf = portal.acl_users uf = portal.acl_users
user = uf.getUserById(kw['reference']) user = uf.getUserById(kw['reference'])
self.assertEqual(str(user), kw['reference']) self.assertEqual(user.getIdOrUserName(), kw['reference'])
self.assertEqual(1, user.has_role(('Member', 'Authenticated',))) self.assertEqual(1, user.has_role(('Member', 'Authenticated',)))
self.login(kw['reference']) self.login(kw['reference'])
self.assertEqual(kw['reference'], self.assertEqual(kw['reference'],
str(portal.portal_membership.getAuthenticatedMember())) portal.portal_membership.getAuthenticatedMember().getIdOrUserName())
# test redirection to person oobject # test redirection to person oobject
path = website.absolute_url_path() + '/WebSite_redirectToUserView' path = website.absolute_url_path() + '/WebSite_redirectToUserView'
......
...@@ -473,7 +473,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -473,7 +473,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
getSecurityQuery instead getSecurityQuery instead
""" """
user = _getAuthenticatedUser(self) user = _getAuthenticatedUser(self)
user_str = str(user) user_str = user.getIdOrUserName()
user_is_superuser = (user == system_user) or (user_str == ERP5Security.SUPER_USER) user_is_superuser = (user == system_user) or (user_str == ERP5Security.SUPER_USER)
allowedRolesAndUsers = self._listAllowedRolesAndUsers(user) allowedRolesAndUsers = self._listAllowedRolesAndUsers(user)
role_column_dict = {} role_column_dict = {}
...@@ -599,7 +599,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -599,7 +599,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
catalogued with columns. catalogued with columns.
""" """
user = _getAuthenticatedUser(self) user = _getAuthenticatedUser(self)
user_str = str(user) user_str = user.getIdOrUserName()
user_is_superuser = (user == system_user) or (user_str == ERP5Security.SUPER_USER) user_is_superuser = (user == system_user) or (user_str == ERP5Security.SUPER_USER)
if user_is_superuser: if user_is_superuser:
# We need no security check for super user. # We need no security check for super user.
......
...@@ -149,10 +149,10 @@ class PreferenceTool(BaseTool): ...@@ -149,10 +149,10 @@ class PreferenceTool(BaseTool):
# reset a security manager without any proxy role or unrestricted method, # reset a security manager without any proxy role or unrestricted method,
# wich affects the catalog search that we do to find applicable # wich affects the catalog search that we do to find applicable
# preferences. # preferences.
actual_user = acl_users.getUser(str(user)) actual_user = acl_users.getUser(user.getIdOrUserName())
if actual_user is not None: if actual_user is not None:
newSecurityManager(None, actual_user.__of__(acl_users)) newSecurityManager(None, actual_user.__of__(acl_users))
tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user, tv_key = 'PreferenceTool._getSortedPreferenceList/%s/%s' % (user.getIdOrUserName(),
sql_catalog_id) sql_catalog_id)
if tv.get(tv_key, None) is None: if tv.get(tv_key, None) is None:
prefs = [] prefs = []
...@@ -284,7 +284,7 @@ class PreferenceTool(BaseTool): ...@@ -284,7 +284,7 @@ class PreferenceTool(BaseTool):
return False return False
tv = getTransactionalVariable() tv = getTransactionalVariable()
tv_key = 'PreferenceTool._isAuthenticationPolicyEnabled.%s' % getSecurityManager().getUser() tv_key = 'PreferenceTool._isAuthenticationPolicyEnabled.%s' % getSecurityManager().getUser().getIdOrUserName()
if tv.get(tv_key, None) is None: if tv.get(tv_key, None) is None:
_isAuthenticationPolicyEnabled = CachingMethod(_isAuthenticationPolicyEnabled, _isAuthenticationPolicyEnabled = CachingMethod(_isAuthenticationPolicyEnabled,
id='PortalPreferences_isAuthenticationPolicyEnabled', id='PortalPreferences_isAuthenticationPolicyEnabled',
......
...@@ -597,7 +597,7 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False): ...@@ -597,7 +597,7 @@ def WorkflowTool_listActions(self, info=None, object=None, src__=False):
key=lambda x: '/'.join((x['workflow_id'], x['worklist_id'])), key=lambda x: '/'.join((x['workflow_id'], x['worklist_id'])),
) )
return action_list return action_list
user = str(_getAuthenticatedUser(self)) user = _getAuthenticatedUser(self).getIdOrUserName()
if src__: if src__:
actions = _getWorklistActionList() actions = _getWorklistActionList()
else: else:
......
...@@ -66,7 +66,7 @@ class FSMailTemplate(BaseMailTemplate,FSPageTemplate): ...@@ -66,7 +66,7 @@ class FSMailTemplate(BaseMailTemplate,FSPageTemplate):
bound_names['options'] = kw bound_names['options'] = kw
security=getSecurityManager() security=getSecurityManager()
bound_names['user'] = security.getUser() bound_names['user'] = security.getUser().getIdOrUserName()
# Retrieve the value from the cache. # Retrieve the value from the cache.
keyset = None keyset = None
......
...@@ -70,7 +70,7 @@ class MailTemplate(BaseMailTemplate,ZopePageTemplate): ...@@ -70,7 +70,7 @@ class MailTemplate(BaseMailTemplate,ZopePageTemplate):
bound_names['options'] = kw bound_names['options'] = kw
security=getSecurityManager() security=getSecurityManager()
bound_names['user'] = security.getUser() bound_names['user'] = security.getUser().getIdOrUserName()
# Retrieve the value from the cache. # Retrieve the value from the cache.
keyset = None keyset = None
......
...@@ -2832,7 +2832,7 @@ class Catalog(Folder, ...@@ -2832,7 +2832,7 @@ class Catalog(Folder,
#'root': ob.getPhysicalRoot(), #'root': ob.getPhysicalRoot(),
#'request': getattr( ob, 'REQUEST', None ), #'request': getattr( ob, 'REQUEST', None ),
#'modules': SecureModuleImporter, #'modules': SecureModuleImporter,
#'user': getSecurityManager().getUser(), #'user': getSecurityManager().getUser().getIdOrUserName(),
# XXX these below are defined, because there is no # XXX these below are defined, because there is no
# accessor for some attributes, and restricted environment # accessor for some attributes, and restricted environment
# may not access them directly. # may not access them directly.
......
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