Hello, Kirk, and sorry about the delay to reply.

TG2 uses repoze.what predicates by attaching them to methods via decorators, 
and so do many people using r.what in Pylons, but not everyone uses them that 
way and repoze.what 1.0 makes no assumption about it, so all the uses are 
perfectly valid.

On the other hand, TG has its own way to route requests to code, while other 
frameworks use other alternatives (i.e., re-using a mapper like Routes or 
Selector, or using their own mechanisms). So, assuming repoze.what kept the 
predicates for each section in your code*, there would be no standard way to 
determinate what predicate(s) belong to the current request.

This is, it'd be out of the scope of a framework-agnostic authorization 
library like repoze.what 1. On the contrary, this task is best suitable for 
the Web frameworks themselves.

repoze.what 2 will handle such routing by itself, so this wouldn't be a 
problem.

* I even have to use the generic word "code" instead of "controllers" or 
"controller actions", because such concepts may be implemented differently 
from one framework to another, or not present at all.

Cheers!

  - Gustavo.


Kirk said:
> 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. :-)
-- 
Gustavo Narea <xri://=Gustavo>.
| Tech blog: =Gustavo/(+blog)/tech  ~  About me: =Gustavo/about |

--~--~---------~--~----~------------~-------~--~----~
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