provide utility function to get groups the current (or a given) user belongs to
This commit is contained in:
parent
3d4b823c8d
commit
b1d70fca1d
1 changed files with 9 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2013 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Utilities for the loops.organize package.
|
Utilities for the loops.organize package.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import interface, component, schema
|
from zope import interface, component, schema
|
||||||
|
@ -31,6 +29,7 @@ from zope.app.security.settings import Allow, Deny, Unset
|
||||||
from zope.securitypolicy.interfaces import IPrincipalRoleManager
|
from zope.securitypolicy.interfaces import IPrincipalRoleManager
|
||||||
from zope.traversing.api import getParents
|
from zope.traversing.api import getParents
|
||||||
from loops.common import adapted
|
from loops.common import adapted
|
||||||
|
from loops.security.common import getCurrentPrincipal
|
||||||
from loops.type import getOptionsDict
|
from loops.type import getOptionsDict
|
||||||
|
|
||||||
defaultAuthPluginId = 'loops'
|
defaultAuthPluginId = 'loops'
|
||||||
|
@ -131,6 +130,13 @@ def getRolesForPrincipal(id, context):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def getGroupsForPrincipal(principal=None):
|
||||||
|
if principal is None:
|
||||||
|
principal = getCurrentPrincipal()
|
||||||
|
gf = getGroupsFolder()
|
||||||
|
return gf.getGroupsForPrincipal(principal.id)
|
||||||
|
|
||||||
|
|
||||||
def getTrackingStorage(obj, name):
|
def getTrackingStorage(obj, name):
|
||||||
records = obj.getLoopsRoot().getRecordManager()
|
records = obj.getLoopsRoot().getRecordManager()
|
||||||
if records is not None:
|
if records is not None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue