Edgewall Software

Opened 12 years ago

Closed 12 years ago

#7201 closed defect (fixed)

PermissionCache doesn't cache when created with __call__

Reported by: Stephen Compall <stephen.compall@…> Owned by: Christian Boos
Priority: highest Milestone: 0.11
Component: general Version: 0.11rc1
Severity: minor Keywords: permission patch
Cc: Branch:
Release Notes:
API Changes:


Discovered in my logs after a user report:

2008-05-06 19:37:35,544 Trac[perm] DEBUG: No policy allowed <redacted> performing TICKET_MODIFY on <Resource 'ticket'>
(repeat 18 times with different timestamps)

I have an IPermissionPolicy that requests actions on perm('ticket') to find them for perm('ticket', id), and then performs an expensive test when that answers false, hence creating the performance issue reported by my user for viewing a single ticket (besides being called multiple times in the first place).

As I see it, the issue is:

>>> cache = {}
>>> cache is not None and cache or 0

(i.e. {} is false) and is fixed in the attached patch.

Attachments (1)

perm-share-empty-cache.diff (519 bytes ) - added by Stephen Compall <stephen.compall@…> 12 years ago.
patch against r7021 (tried on 0.11rc1)

Download all attachments as: .zip

Change History (3)

by Stephen Compall <stephen.compall@…>, 12 years ago

Attachment: perm-share-empty-cache.diff added

patch against r7021 (tried on 0.11rc1)

comment:1 by Christian Boos, 12 years ago

Keywords: permission added
Milestone: 0.11
Owner: changed from Jonas Borgström to Christian Boos
Priority: normalhighest
Status: newassigned

Oops, right, good catch!

comment:2 by Christian Boos, 12 years ago

Resolution: fixed
Status: assignedclosed

Patch applied in r7022, with some unit-tests.

Getting the unit-tests to work implied disabling the cache at the level of the DefaultPermissionPolicy, which makes me think that cache could eventually lead to transient permission issues (like an admin complaining that the removal of a permission for anonymous didn't take effect immediately - ok, it's a matter of waiting 5 seconds, so nothing critical).

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Christian Boos to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.