Commit 56255f73 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

py2/py3: rewrite Base_viewSecurity with py2/py3 compatible way of print().

parent 68c3f84b
......@@ -6,18 +6,18 @@ u = getSecurityManager().getUser()
user_value = u.getUserValue()
if user_value is None:
print 'User ID:', u.getId()
print('User ID: %s' % u.getId())
else:
print 'User ID:', u.getId(), user_value.getPath()
print('User ID: %s %s' % (u.getId(), user_value.getPath()))
login_value = u.getLoginValue()
if login_value is None:
print 'Login:', u.getUserName()
print('Login: %s' % u.getUserName())
else:
print 'Login:', u.getUserName(), login_value.getPath()
print 'Is owner:', u.allowed(context,('Owner',))
print 'User roles:', u.getRoles()
print 'User roles in context:', u.getRolesInContext(context)
print 'Permissions:'
print('Login: %s %s' % (u.getUserName(), login_value.getPath()))
print('Is owner: %s' % u.allowed(context,('Owner',)))
print('User roles: %s' % u.getRoles())
print('User roles in context: %s' % u.getRolesInContext(context))
print('Permissions:')
for permission in [
'Access contents information',
'Add portal content',
......@@ -26,25 +26,25 @@ for permission in [
'View',
'Manage portal',
]:
print " ", permission, u.has_permission(permission, context)
print(" %s %s" % (permission, u.has_permission(permission, context)))
print
print('')
try:
print "User groups:\n", pformat(sorted(u.getGroups()))
print("User groups:\n%s" % pformat(sorted(u.getGroups())))
except AttributeError:
print 'no getGroups'
print('no getGroups')
print
print 'Local roles on document:\n', pformat(context.get_local_roles())
print('')
print('Local roles on document:\n%s' % pformat(context.get_local_roles()))
print '''
print('''
----------------
Security mapping
----------------'''
----------------''')
if u.getId() is not None:
try:
print context.Base_viewSecurityMappingAsUser(u.getId())
print(context.Base_viewSecurityMappingAsUser(u.getId()))
except Unauthorized:
print "user doesn't have permission to security mapping in this context"
print("user doesn't have permission to security mapping in this context")
return printed
......@@ -16,12 +16,12 @@ for method_id, base_category_list in getSecurityCategoryMapping():
security_category_dict.setdefault(tuple(base_category_list), []).extend(
getattr(context, method_id)(base_category_list, login, context, ''))
except Exception: # XXX: it is not possible to log message with traceback from python script
print 'It was not possible to invoke method %s with base_category_list %s'%(method_id, base_category_list)
print('It was not possible to invoke method %s with base_category_list %s'%(method_id, base_category_list))
for base_category_list, category_value_list in security_category_dict.items():
print 'base_category_list:', base_category_list
print('base_category_list: %s' % (base_category_list,))
for category_dict in category_value_list:
print '-> category_dict:', category_dict
print '-->', group_id_list_generator(category_order=base_category_list,
**category_dict)
print('-> category_dict: %s' % category_dict)
print('--> %s' % group_id_list_generator(category_order=base_category_list,
**category_dict))
return printed
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