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.

Thanks

Cosmia

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-devel/-/ALgwm2dw6ysJ.
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