Opened 16 years ago
Closed 16 years ago
#3358 closed defect (wontfix)
TracTags 0.6 appears to break IPermissionPolicy example
Reported by: | James Yonan | Owned by: | Alec Thomas |
---|---|---|---|
Priority: | normal | Component: | TagsPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
This is an important example showing how to build a fine-grained permission policy using tags:
http://cmrg.fifthhorseman.net/browser/trunk/tracplugins/publictags/public_tags.py
The sample now appears to be broken, due to non-existence of TagEngine object in TracTags 0.6.
It would be great if someone who understands TracTags 0.6 could fix this example, or point me to an IPermissionPolicy sample that uses the new TracTags 0.6 API.
Thanks, James
Attachments (1)
Change History (4)
comment:1 Changed 16 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 16 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Trac Release: | 0.10 → 0.11 |
I was able to fix the issue, but I had to add a small patch (attached) to api.py to allow get_resource_tags to be called with req==None, since the IPermissionPolicy plugin might want to query the tags for a page outside the context of a request for that page.
After adding this patch, it is then possible to easily get the tags for a resource in an IPermissionPolicy plugin as such:
tags = TagSystem(self.env).get_tags(None, resource)
I added the patch since it was not clear to me how an IPermissionPolicy plugin could pass a reasonable 'req' object given the context in which it is called. In fact, it would seem that if the IPermissionPolicy plugin passed the current request object, it would set up an infinite recursion because the IPermissionPolicy plugin would get recursively called again asking if TAGS_VIEW is permitted on the requested page.
Please merge if this seems like a reasonable approach.
comment:3 Changed 16 years ago by
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
req
usage is pervasive in Trac, selectively avoiding it isn't really feasible. Fortunately, Trac provides a couple of mock objects that are perfect for this situation:
from trac.tests import Mock, MockPerm req = Mock(perm=MockPerm()) ...
Urm , you'd be better off creating this ticket on that Trac rather than here.