Mercurial > p > roundup > code
comparison roundup/security.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 | 34434785f308 |
| children | 261c9f913ff7 |
comparison
equal
deleted
inserted
replaced
| 4305:e39b88a7150a | 4306:966592263fb8 |
|---|---|
| 160 when invoked, must return a True value. | 160 when invoked, must return a True value. |
| 161 | 161 |
| 162 Note that this functionality is actually implemented by the | 162 Note that this functionality is actually implemented by the |
| 163 Permission.test() method. | 163 Permission.test() method. |
| 164 ''' | 164 ''' |
| 165 roles = self.db.user.get(userid, 'roles') | |
| 166 if roles is None: | |
| 167 return 0 | |
| 168 if itemid and classname is None: | 165 if itemid and classname is None: |
| 169 raise ValueError, 'classname must accompany itemid' | 166 raise ValueError, 'classname must accompany itemid' |
| 170 for rolename in [x.lower().strip() for x in roles.split(',')]: | 167 for rolename in self.db.user.get_roles(userid): |
| 171 if not rolename or not self.role.has_key(rolename): | 168 if not rolename or not self.role.has_key(rolename): |
| 172 continue | 169 continue |
| 173 # for each of the user's Roles, check the permissions | 170 # for each of the user's Roles, check the permissions |
| 174 for perm in self.role[rolename].permissions: | 171 for perm in self.role[rolename].permissions: |
| 175 # permission match? | 172 # permission match? |
