On Wed, 2012-02-01 at 20:11 -0800, Cosmia Luna wrote:
> I'm a beginner in both python and pyramid, sorry if my question is
> silly.
> I'm using class-based view-callable in pyramid.
> 
> 
> In package.views.someview, I usually write:
> 
> 
> # -*- coding: utf-8 -*-
> from pyramid.view import view_config
> from pyramid.response import Response
> from cgi import escape
> 
> 
> class SomeView(object):
>     def __init__(self, req):
>         self.req=req
>         # and something other to for things repeatly
>     
>     def __call__(self):
>         # Usually not used
>         return Response("This is the page from __call__ of %s" %
> escape(repr(self)))
>     
>     @view_config('add', context='package.views.someview.SomeView')
>     def add(self):
>         return Response("This is the page from add of %s" %
> escape(repr(self)))
>     
>     @view_config('edit', context='package.views.someview.SomeView')
>     def edit(self):
>         return Response("This is the page from edit of %s" %
> escape(repr(self)))
> 
> 
>     @view_config('view', context='package.views.someview.SomeView')
>     def view(self):
>         return Response("This is the page from view of %s" %
> escape(repr(self)))
> 
> 
>     @view_config('delete', context='package.views.someview.SomeView')
>     def delete(self):
>         return Response("This is the page from delete of %s" %
> escape(repr(self)))
>         
> 
> This is really boring and makes no sense to specify the name and the
> context of the view every time, how can I do that automatically? I
> have to specify name because I use traversal approach to map URLs, and
> I have to specify the context because of view name conflict.

http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/viewconfig.html#view-defaults-class-decorator

1.3a5 or better required.

- C



-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to