Hey All, Sorry all. I accidentally submitted my message somehow.
I wanted to say that I like the direction Django is going compared to the other Python frameworks for its routing. I've looked at Express.js, angularjs, rails, and MVC.NET as well. And Django is definitely the easiest to read among them. I think this syntax offers both simplicity in not missing dumb stuff like the leading ^ and the trailing $, but it also lets us work toward more expressive routing patterns in the future. Robert Roskam On Wednesday, October 5, 2016 at 4:08:08 PM UTC-4, Robert Roskam wrote: > > Hey Tom, > > I really like your current implementation. I think it's an elegant > solution to a complex problem, and I like that you looked at Flask for some > inspiration. > > I thought that to round out the discussion I'd do a quick comparison to > other frameworks. (I've added in slug examples): > > *Django* > > urlpatterns = [ > url(r'^articles/2003/$', views.special_case_2003), > url(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive), > url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', > views.month_archive), > url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', > views.article_detail), url(r'^articles/(?P<slug>[\w-]+)/$', > views.slug_view), > ] > > > > *DEP* > > urlpatterns = [ > path('articles/2003/', views.special_case_2003), > path('articles/<int:year>/', views.year_archive), > path('articles/<int:year>/<int:month>/', views.month_archive), > path('articles/<int:year>/<int:month>/<int:day>/', views.article_detail), > path('articles/<string:slug>/', views.slug_view), > ] > > > > > > *Flask* > Doesn't really have the idea of putting all your routes in one spot. So > pardon the silly example. > > > @app.route('articles/2003/') > def special_case_2003(): > pass > > @app.route('articles/<int:year>/') > def year_archive(year): > pass > > @app.route('articles/<int:year>/<int:month>/') > def month_archive(year, month): > pass > > @app.route('articles/<int:year>/<int:month>/<int:day>/') > def article_detail(year, month, day): > pass > > @app.route('articles/<string:slug>/') > def slug_view(slug): > pass > > > > > *Bottle* > It's basically Flask (big surprise). > > @route('articles/2003/') > def special_case_2003(): > pass > > @route('articles/<year:int>/') > def year_archive(year): > pass > > @route('articles/<year:int>/<month:int>/') > def month_archive(year, month): > pass > > @route('articles/<year:int>/<month:int>/<day:int>/') > def article_detail(year, month, day): > pass > > @route('articles/<slug:string>/') > def slug_view(slug): > pass > > > > > > > *Pyramid* > This one is kind of interesting. They don't have any built in validators. > And they call their equivalent predicates > <http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/hooks.html#view-and-route-predicates>, > > and their usage is far more board. > > config.add_route('special_case_2003', 'articles/2003/') > config.add_route('year_archive', 'articles/{year}/') > config.add_route('month_archive', 'articles/{year}/{month}/') > config.add_route('article_detail', 'articles/{year}/{month}/{day}/') > config.add_route('slug_view', 'articles/{slug}/') > config.scan() > > > > > > > Robert Roskam > > On Monday, October 3, 2016 at 6:24:04 AM UTC-4, Tom Christie wrote: >> >> Hi folks, >> >> I wanted to push forward the consideration of introducing a simpler URLs >> syntax, plus support for URL parameter type conversion. >> >> A pre-proposal is available here: >> https://gist.github.com/tomchristie/cb388f0f6a0dec931c611775f32c5f98 >> >> At this point I'm seeking feedback, before hopefully iterating on the >> proposal, and making a formal submission. >> >> I'm not making any assumptions right now about where this might get too, >> or who'd be involved if it does make it to the DEP stage, and would very >> much welcome outside involvement. I'm also aware that while there's been >> some positive reception, it's not yet clear if we'll reach a consensus on >> inclusion in core. >> >> Personally I'm very firmly +1 on this, as I feel that the existing syntax >> is a rather glaring and unnecessary pain point. >> >> Thanks to everyone who's started to kick this off, in particular Emil >> Stenström for raising the original thread, and Sjoerd Job Postmus for their >> work on the Django Simple URL >> <https://github.com/sjoerdjob/django-simple-url> package. >> >> - Tom >> > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/db1f38e2-3716-41d0-870e-ea7b84d0cfc6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.