Hi list

I have many RESTControllers, put and get method's signatures typically
are something like

 def put(self, item_id, **kwargs):


now I want to implement a row based permission predicate decorator


    @require(has_access('write'))
    def put(self, item_id, **kwargs):


the predicate inherits from
from repoze.what.predicates import Predicate

it's import method is evaluate

    def evaluate(self, environ, credentials):
        try:
            current_user = environ['repoze.who.identity']['user']
        except KeyError: # anonymous
            self.unmet()

        url = environ['pylons.routes_dict']['url']
....


now from the environ I need to determine the item id
I tried using the url like above, but then I need an overcomplex regex
to find the item_id

url might be something like :

http://127.0.0.1/items/8.xml/?extra=452546587

I also tried

        vars = self.parse_variables(environ)
        pos_args = vars.get('positional_args')
        if pos_args:
            obj_id = pos_args[0]

but in some cases obj_id is evaluated to a URLGenerator object

well, my question is, from the environ how can I best determine the
positional arguments ?

regards

NIL

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