``request_method`` is limited to comparison with a single query
parameter. To add more complex behavior you will need to use a custom
predicate.
Note that you are not required to use 2 routes here... After the pattern is
matched for your route, there is view lookup performed based on the *view*
predicates. For example:
config.add_route('readPage', '/SupportMapAdmin/api')
config.add_view(sortView, route_name='readPage', request_param='sort')
config.add_view(startAndLimitView, route_name='readPage',
request_param='start')
config.add_view(startAndLimitView, route_name='readPage',
request_param='limit')
OR, if this is too verbose, a custom predicate:
def custom_param_predicate(*params):
def predicate(context, request):
return any([param in request.params for param in params])
return predicate
config.add_route('readPage', '/SupportMapAdmin/api')
config.add_view(sortView, route_name='readPage', request_param='sort')
config.add_view(startAndLimitView, route_name='readPage',
custom_predicates=(custom_params_predicate('start', 'limit'),))
It is also possible to do this with route predicates instead of view
predicates, but I'm not sure why you would want to necessarily unless the
different groups of views set different traversal paths or root factories.
--
Michael
--
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.