Edgewall Software

Changes between Version 13 and Version 14 of CookBook/PermissionPolicies


Ignore:
Timestamp:
May 8, 2017, 1:31:00 AM (7 years ago)
Author:
Ryan J Ollos
Comment:

Fix ResourceNotFound error when ticket doesn't exist.

Legend:

Unmodified
Added
Removed
Modified
  • CookBook/PermissionPolicies

    v13 v14  
    153153from trac.core import *
    154154from trac.perm import IPermissionPolicy, IPermissionRequestor
     155from trac.resource import ResourceNotFound
    155156from trac.ticket.model import Ticket
    156157
     
    177178                resource.id is not None and \
    178179                'TICKET_VIEW_REPORTED' in perm:
    179             ticket = Ticket(self.env, resource.id)
    180             return ticket['reporter'] == username
     180            try:
     181                ticket = Ticket(self.env, resource.id)
     182            except ResourceNotFound:
     183                pass
     184            else:
     185                return ticket['reporter'] == username
    181186}}}
    1821871. Edit the `permission_policies` option in the [TracIni#trac-section "[trac]"] section of trac.ini, adding the `SupportDeskPolicy` component ''before'' the default [TracPermissions permission] policy: