Gustavo,

following the info here:

http://static.repoze.org/whatdocs/Manual/Predicates/Writing.html#creating-a-predicate-checker-more-sensitive-to-the-request

I tried to use:

vars = self.parse_variables(environ)

and I got:

AttributeError: 'tuple' object has no attribute 'get'

to fix this I attached a small patch that makes sure a dict is return
instead of a tuple to the offending line.

Unfortunately from what I can see I don't have the the elements on my url:

same example as before:

/mycontroller/editmethod/post-slug

with a controller like this:

class RootController(BaseController):
    @expose('myapp.templates.index')
    @require(mypredicate())
    def editmethod(self, slug):
        ...

this works in TG2 without routes and the editmethod will get the post
slug as a positional parameter thanks to object dispatch. But If I
protect it with the @require decorator, the result of:

vars = self.parse_variables(environ)

in the said decorator contains only empty variables for all the
variables. Which seem logical since there is no post/get vars in my
url.

The solution I proposed a few days ago was to have a possibility for
the TG2 object dispatcher to call the check_auth with the parameters
(python params) that are computed by object dispatch. This is the only
way my predicate will ever know that post-slug is an actual argument
to my actual controller without fiddling in the url by itself...

Florent.
Index: repoze/what/predicates.py
===================================================================
--- repoze/what/predicates.py   (révision 3584)
+++ repoze/what/predicates.py   (copie de travail)
@@ -313,7 +313,7 @@
             post_vars = parse_formvars(environ, False) or {}
         except KeyError:
             post_vars = {}
-        routing_args = environ.get('wsgiorg.routing_args', {})
+        routing_args = environ.get('wsgiorg.routing_args', (None, {}))[1]
         positional_args = routing_args.get('positional_args') or ()
         named_args = routing_args.get('named_args') or {}
         variables = {

_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to