I see. I guess it just seemed odd to me not to have a default behavior where a route would be matched automatically to the appropriately named class/function, but I guess that makes Pyramid a more flexible platform. Thank you.
On Tuesday, April 3, 2012 8:30:52 AM UTC-5, Michael Merickel wrote:
Well you can certainly do it yourself with the "add_my_route" function that you create that calls both for you... Otherwise, no, it's by design in Pyramid that routes and views are separate concepts.
You can always use traversal, and then it's just a single add_view call with no add_route. :-)
On Tue, Apr 3, 2012 at 6:52 AM, Zak wrote:
I want to map a route to a class-based view without needing to name the class again in a view-config decorator and without needing to explicitly name it in a config.add_view in the __init__.
I want
config.add_route('MyClass', '/')
to map that route to
@view_defaults(renderer='string')
class MyClass(object):
def __init__(self, request):
self.request = request
def __call__(self):
return 'a string'
without needing any extra code. Is this possible?