I would like to see a replacement for the regex scheme as well, but not 
because I am uncomfortable with regexes.  I think the typical regex for 
a URL is noisy: it's hard to see the intent of the expression.  Most URL 
regexes follow some very well-defined patterns, and we don't have a way 
to express them other than to "compile them down" to regexes.  Sometimes 
you need the full power, but usually, your URL consists of fixed parts 
and variable parts separated by slashes.  The variable parts are often 
numbers, or slugs, and need to be given names.  Being able to express 
that succinctly would solve most people's URL matching.

I don't have a suggestion for a replacement, and I don't think it needs 
to be on the 1.0 list (since it can be added without breaking backward 
compatibility), but I think it would be a big plus.

--Ned.
http://nedbatchelder.com/blog

Simon Willison wrote:
> On 4 Dec 2007, at 13:26, bobj wrote:
>
>   
>> Simon - These are GREAT!!! Ideas. The regular expression based URL
>> dispatching  replacement has been something I personally have been
>> thinking about for some time.  I would be interested in helping with
>> this If you put together a proposal. One URL implementation worth
>> considering is "Routes" ( http://routes.groovie.org ). I have used
>> Routes for web applications and I think it is easy to grok. Have you
>> taken a look at Routes?
>>     
>
> I like Routes in principle, but the way it has the concept of a  
> "controller" baked in to it didn't sit very well with me. I can't  
> imagine it would be hard to use it without controllers though.
>
> I'm generally pretty happy with regular expressions, but I watched  
> Scott Guthrie's presentation on the ASP.NET MVC framework a few weeks  
> ago (it's really interesting, they've taken a bunch of ideas from  
> Django and it gets name-checked in the presentation) and one of the  
> things he noted is that there are developers (especially in the  
> Microsoft ecosystem) who never really got comfortable with regexps. I  
> don't want those people to be turned away from Django on the first  
> page of the tutorial. He also described the ASP.NET MVC syntax for  
> URLs, which looks like this:
>
> search/[query]
> product/[id]
>
> http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc- 
> framework-part-2-url-routing.aspx
>
> While I personally prefer the power of regexps, I can see how the  
> above would make it much easier for developers just beginning to get  
> their feet wet with Django. We can always enlighten them with the  
> power of regular expressions once they're hooked. If URL handling is  
> interchangeable we can have the best of both worlds. Incidentally,  
> allowing URL logic to be swapped out was an initial design goal back  
> when we put the URL stuff together - we were worried about  
> performance, but when we benchmarked it turned out that Python can  
> run through a list of a hundred or so regular expressions in less  
> than 0.01 seconds.
>
> Cheers,
>
> Simon
>
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to