Jan 14
To add permissions to Trac 0.11 you simply need to add a myPermissions.py file to your Trac environment plugin folder that looks like this:
from trac.core import Component, implements
from trac.perm import IPermissionRequestor
class MyPermissions(Component):
implements(IPermissionRequestor)
def get_permission_actions(self):
return ('MY_FIRST_PERM', 'MY_SECOND_PERM')
Add your set of permissions to the return command in place of 'MY_FIRST_PERM', 'MY_SECOND_PERM', restart apache and you should be away.
You can now use these permission in your work flow against actionname.permissions entries.
NOTE: you don't need to call the file "myPermissions.py" - its just needs to be a python file with a name of your choosing.
Mar 25, 2008 at 5:24 PM Hi,
Your sugesttion will be very useful. Although I can't use this script. I have just copy and paste your lines in a new file named myPermissions.py(I know this name is just a suggestion..) inside my plugin folder and restart the server. My server is a standalone application. Could you help me, please?
Thanks,
Sep 3, 2008 at 2:53 PM Probably due to the fact that this web site doesn't allow any formatting or [code] tags.
if you aren't familiar with python, the following needs to be done:
class MyPermissions(Component):
4 spaces->implements(IPermissionRequestor)
4 spaces->def get_permission_actions(self):
8 spaces->return ('MY_FIRST_PERM',#39;MY_SECOND_PERM')
the last line is also a single line like: return (...)
don't forget the extra indent.
4/8 spaces are arbitrary, they just has to match that section of code consistently, 3, 6 will work, 2, 5 will work...etc.
Sep 8, 2008 at 10:58 PM Sorry for not getting back to you before now.
You are correct. The indentation in python is important and I apologise for the broken code formatting... I'm working on resolving that one as soon as possible.