Mercurial > p > roundup > code
diff roundup/cgi/templating.py @ 4306:966592263fb8
Clean up all the places where role processing occurs.
This is now in a central place in hyperdb.Class and is used
consistently throughout. This also means now a template can override
the way role processing occurs (e.g. for elaborate permission
schemes). Thanks to intevation for funding the change.
Note: On first glance the hyperdb.Class may not be the ideal place for
role processing. On second thought: Roles may appear in other classes,
too (e.g., a user_group or similar) which then don't need to reinvent
the wheel. And I didn't want to introduce a separate UserClass (as is
the case for the HTML classes) due to compatibility issues with existing
schema.py out there.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Tue, 15 Dec 2009 15:11:27 +0000 |
| parents | ce684080e968 |
| children | 3d224f7fb364 |
line wrap: on
line diff
--- a/roundup/cgi/templating.py Mon Dec 14 21:48:51 2009 +0000 +++ b/roundup/cgi/templating.py Tue Dec 15 15:11:27 2009 +0000 @@ -1205,12 +1205,9 @@ return self._db.security.hasPermission(permission, self._nodeid, classname, property, itemid) - def hasRole(self, rolename): - """Determine whether the user has the Role.""" - roles = self._db.user.get(self._nodeid, 'roles').split(',') - for role in roles: - if role.strip() == rolename: return True - return False + def hasRole(self, *rolenames): + """Determine whether the user has any role in rolenames.""" + return self._db.user.has_role(self._nodeid, *rolenames) def HTMLItem(client, classname, nodeid, anonymous=0): if classname == 'user':
