我無法獲得Thomas Jungs示例工作。我能夠通過迭代密鑰而不使用iteritems()來獲得Thomas Jung的示例。
def matchdict_default(**kw):
def f(info, request):
for k in kw:
info['match'].setdefault(k, kw[k])
return True
return f
config.add_route(
'show_files',
'/show_files/{datasetid}/{page}')
config.add_route(
'show_files',
'/show_files/{datasetid}',
custom_predicates=(matchdict_default(page=1),))`
now both of the following urls resolve to the page value, and, urls
can be created without needing to include a query
parameter
/show_files/an_id/
/show_files/an_id/?page=1
謝謝,餘下的比賽是我錯過了 – Chris 2012-04-28 18:27:45