99 | | From [http://nil.checksite.co.uk/index.cfm/2008/1/14/trac-0-11-creating-your-own-permissions] |
100 | | |
101 | | To add permissions to you simply need to add a myPermissions.py file to your Trac environment plugin folder that looks like this: |
102 | | |
103 | | |
104 | | {{{ |
105 | | from trac.core import Component, implements |
106 | | from trac.perm import IPermissionRequestor |
107 | | class MyPermissions(Component): |
108 | | implements(IPermissionRequestor) |
109 | | def get_permission_actions(self): |
110 | | #comma separated list of new permissions |
111 | | return ('TICKET_CLOSE','TICKET_DEFER') |
112 | | }}} |
113 | | |
114 | | 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. |
115 | | |
116 | | You can now use these permission in your work flow against actionname.permissions entries. |
117 | | |
118 | | 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. |
| 98 | |
| 99 | To create custom permissions, for example to be used in a custom workflow, enable the optional `tracopt.perm.config_perm_provider.ExtraPermissionsProvider` component in the "Plugins" admin panel, and add the desired permissions to the `[extra-permissions]` section in your [wiki:TracIni#extra-permissions-section trac.ini]. For more information, please refer to the documentation of the component in the admin panel. |