Re: Parse URLs to integers

2009-09-23 Thread Daniel Roseman
On Sep 23, 5:24 pm, IanSR wrote: > Is there some trick to parse > > http://www.example.com/foo/42 > > such that "42" becomes an integer parameter to the view function, > instead of a string? > > Right now I have to do: > > from my.app.views import foo > > urlpatterns = patterns('', > (r'foo/(

Parse URLs to integers

2009-09-23 Thread IanSR
Is there some trick to parse http://www.example.com/foo/42 such that "42" becomes an integer parameter to the view function, instead of a string? Right now I have to do: from my.app.views import foo urlpatterns = patterns('', (r'foo/(?P\d+)/?$', foo), ) my/app/views.py def foo(reque