Trac 0.11: Creating your own permissions

To add permissions to Trac 0.11 you simply need to add a file to your Trac environment plugin folder that looks like this:


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 "" - its just needs to be a python file with a name of your choosing.


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 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?

# Posted By Roberto | 3/25/08 5:24 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.
# Posted By PythonGuy | 9/3/08 2:53 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.
# Posted By Stephen Moretti | 9/8/08 10:58 PM
And one more hint: don't write & # 39 ; instead use quotes!

Apart from this, it works fine!
# Posted By jofo | 10/23/08 7:00 PM
yep - if the code tag was working correctly on my blog it would display as " rather than as the escape code.
# Posted By Stephen Moretti | 10/23/08 8:38 PM