- From: Jacob Kaplan-Moss <jacob@jacobian.org>
- Date: Thu, 5 Oct 2006 11:51:35 -0500
- To: uri@w3.org
Howdy folks -- So are there any plans to add some sort of validation of template parameters to this spec? That is, I would love to be able to specify in a URI template that a particular parameter must be an integer, or must be less than five characters long, or... A bit of background: I work on Django (http:// www.djangoproject.com/), an open-source web framework. One of the core bits of Django is a resolver that maps the requested path to a function (view) responsible for rendering that page. This resolver currently uses regular expressions, so a simple set of URLs for a blog might look like:: urlpatterns = patterns('', ('^blog/$', blog_index) ('^blog/(?P<entry_id>\d+)/$', entry_page) ) (i.e. URIs like ``http://example.com/blog/`` and ``http://example.com/ blog/145/``). This works pretty well for people who understand regexes -- it lets me do some really powerful things -- but for the newcomer and the common case something like this URI template proposal would be much nicer. So I'd love to be able to use this (proposed) standard for URI resolution within Django. However, having to do all validation within view code instead of within the URI template itself is going to get old really quick. In the above example, in my ``entry_page`` view I can be sure that the parameter captured from the regex is an integer; in a URI template:: /blog/{entry_id}/ I'd have to check ``entry_id`` in that view and in every other one. I don't really have anything concrete to propose here, but if some form of validation of parameters is a possibility, I'm happy to spend some time thinking about ways it could fit into the spec. Thanks! Jacob
Received on Friday, 6 October 2006 02:15:30 UTC