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