thanks
this is exactly what the predicate.parse_variables does
...snip..
routing_args = environ.get('wsgiorg.routing_args', ([], {}))
positional_args = routing_args[0] or ()
named_args = routing_args[1] or {}
variables = {
'post': post_vars,
'get': get_vars,
'positional_args': positional_args,
'named_args': named_args}
return variables
but it sometimes return a URLGenerator object
....
On Apr 20, 12:15 pm, "Diez B. Roggisch" <[email protected]> wrote:
> On Wednesday, April 20, 2011 11:52:55 am NiL wrote:
>
>
>
> > 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 ?
>
> I'm not sure, but aren't they under wsgiorg.routingargs or some such?
>
> Diez
--
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.