On Friday 17 July 2009 07:23:12 pm Gustavo Narea wrote:

> I'm afraid there's no sane/DRY way to do this, unfortunately, because of
> the way repoze.what 1 works. The problem is that the conditions are
> attached via decorators, which can be wrapped around (hidden) by other
> decorators, which leaves us with no reliable way to get the predicate. Of
> course, this doesn't apply to controller-wide authorization via
> .allow_only.

Could repoze.what 1 be (easily) modified to track its predicate decorators?  
For example, suppose:

    def predicate(value):
        def decorate(func):
            attrs = getattr(func, 'predicates', [])
            attrs.append(value)
            setattr(func, 'predicates', attrs)
            return func
        return decorate

    @predicate('something')
    @predicate('another')
    def bar(test):
        print 'Test: ', test

    print bar.predicates

If the Predicate base class had something like that in .__init__, could it be 
used to deterministically build the list of predicates that were being applied 
to an action?

I apologize for asking this before examining the code in question, but you 
might be able to answer in 3 seconds what might take me a day to find.  Also, 
brainstorming is fun. :-)
-- 
Kirk Strauser

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to