Menu

Commit [r4556]  Maximize  Restore  History

PermissionPolicy: reworked a bit the !ResourceSystem

{{{
#!python
class IResourceMapper(Interface):
"""Map between Trac resources and their corresponding contexts."""

def get_resource_factories():
"""Generator yielding `(realm, resource_factory)` pairs.

The `resource_factory` is a function taking a `Context` and
returning an instance of a Resource subclass.
"""

def get_context_classes():
"""Generator yielding `(realm, context_subclass)` pairs."""
}}}

Example implementation:
{{{
#!python
# IResourceMapper methods

def get_resource_factories(self):
def wiki_page_factory(context):
from trac.wiki.model import WikiPage
assert context.resource == 'wiki'
return WikiPage(self.env, context.id)
# TODO: add `context.version` after blame integration
yield ('wiki', wiki_page_factory)

def get_context_classes(self):
return [] # base Context is OK so far, but could be:
# yield ('wiki', WikiContext)
}}}

More Context related changes:
- finish the s/resource/realm/ renaming started in r4552
- rename s/object/resource/
- `from_resource(req, resource)` doesn't need an env parameter,
as this is assumed to be available from the `resource`
- I think the above method is enough for getting a Context from a resource,
so I've reverted r4551
- fixed the `__call__` method and make it clearer
- documentation updates

In the !PermissionCache, effectively cache the results of the permission check. Ideally, those results should be cached at the Request level, I think.

cboos 2007-01-12

changed /sandbox/security/templates/attachment.html
changed /sandbox/security/templates/macros.html
changed /sandbox/security/trac/attachment.py
changed /sandbox/security/trac/perm.py
changed /sandbox/security/trac/resource.py
changed /sandbox/security/trac/ticket/api.py
changed /sandbox/security/trac/ticket/report.py
changed /sandbox/security/trac/wiki/api.py
changed /sandbox/security/trac/wiki/macros.py
changed /sandbox/security/trac/wiki/model.py
changed /sandbox/security/trac/wiki/web_ui.py
/sandbox/security/templates/attachment.html Diff Switch to side-by-side view
Loading...
/sandbox/security/templates/macros.html Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/attachment.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/perm.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/resource.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/ticket/api.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/ticket/report.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/wiki/api.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/wiki/macros.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/wiki/model.py Diff Switch to side-by-side view
Loading...
/sandbox/security/trac/wiki/web_ui.py Diff Switch to side-by-side view
Loading...
Auth0 Logo