On Mon, Apr 17, 2006 at 03:20:48PM +1000, Alec Thomas wrote:
>     class Resource(object):
>         """ Base class for all resources in Trac. """
> 
>         type = None
>         id = None
> 
>         def __init__(self, id=None):
>             if id is not None:
>                 self.id = id
> 
>         def __repr__(self):
>             suffix = self.id is not None and ':' + self.id or ''
>             return "<Resource %s%s>" % (self.type, suffix)

What's the opinion on adding Resource as a base class of Component?
ComponentMeta would automagically set the id to the name of the
component. Permissions could then be applied to the components
themselves, which seems fairly useful.

eg. in Search:

    def get_navigation_items(self, req):
        if not req.perm.has_permission('VIEW', self):
            return
        ...

eg.

    >>> from trac.env import Environment
    >>> e = Environment('../env/security')
    >>> e.type
    component
    >>> e.id
    environment
    >>> e
    <Resource component:environment>

-- 
Evolution: Taking care of those too stupid to take care of themselves.
_______________________________________________
Trac-dev mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-dev

Reply via email to