In pyramid when using traversal url lookup, is it possible to have the view lookup algorithm check for method names of a class. For example, I could do something like this:
@view_defaults(context=models.Group)
class GroupView(object):
def __init__(self, context, request):
self.context = context
self.request = request
@view_config(name='members')
def members(self):
pass
to match let's say /groups/somegroup/members
Is there a way to make the name lookup part dynamic? That is, something like this:
@view_defaults(context=models.Group)
class GroupView(object):
def __init__(self, context, request):
self.context = context
self.request = request
def members(self):
pass
def add(self):
pass
So that both /groups/somegroup/members and /groups/somegroup/add will both resolve to their respective methods of the class?
Can't say this is the
best
way (I don't know anything about pyramid); but one option might be to just decorate the class with a decorator that decorates the method names appropriately. eg.