On Sat, 2012-02-04 at 13:35 +0100, Benjamin Hepp wrote:
> Hi,
> 
> hmm, I overlooked this in the docs. So the method name is taken as the
> view_name? Couldn't find this in the docs.

No, you still have to use @view_config(name=..) for each method, there's
no implicit method-name to name= mapping.

> But I'm still having some trouble with it. I have something like this:
> @view_defaults(context=A, name='update')
> class UpdateHandler(object):
>       ...
>       @view_config(predicates...)
>       def update1(self):
>               ...
> 
>       @view_config(context=B, predicates...)
>       def update2(self):
>               ...
> 
> When I leave out the "context=B" it works, but when I put it in the
> update1 view is not found anymore. I think the context=B overwrites the
> context of the whole class, is that possible??

Without @view_defaults I'd expect your example above to translate to:

class UpdateHandler(object):
    ....
    @view_config(context=A, name='update', predicates...):
    def update1(self):
        ....

    @view_config(context=B, name='update', predicates...):
    def update2(self):
        ....

Is that your expectation?  When you do it like that instead of using
view_defaults, do you get the same outcome?

For the record, you really do need to use 1.3a5+; there was a bug in
@view_defaults before then that made it not work right.

> 
> Though maybe I still go for extending this behaviour (I also would like
> to have a general cleanup() method in my handler without having to call
> it). So is a view_mapper the right way to do this?

View mappers can be used to do all sorts of rearranging, yes.

- C


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to