On Sep 15, 12:04 pm, Ivan Sagalaev <man...@softwaremaniacs.org> wrote: > James Bennett wrote: > > Except I can't help thinking this is an awfully arbitrary distinction > > to draw. In effect you're saying that nearly every question about an > > object should be answerable by interrogating it directly, *except* for > > "what's a URL I can use for you?" > > May be I can explain this distinction with an example. > > We once had two different web sites about "events". They both had a > "core" set of models but each one had their own set of views & urls. So > for a core Event model a question "what's your URL" just didn't make > sense. It had two different URLs depending on the project it was > imported in.
For me, this one boils down to pragmatism v.s. purity. >From a purity point of view, having models that know what their URLs are when Django's concept of a URL is defined in the urls.py file is an obvious violation of separation of concerns. >From a pragmatism point of view, being able to ask an object it's URL is incredibly convenient - and in 90% of the projects I've worked on in the past few years each object has had one and only one URL (in fact REST principles actively encourage this). I'm OK with .get_url() and .get_url_path() (I still prefer the semantics and names used in my original proposal to any of the proposed alternatives) only being useful 90% of the times, with projects where objects can have more than one URL needing to find some alternative method. As for running code, allow me to point to http://code.google.com/p/django-urls/ :) Cheers, Simon --~--~---------~--~----~------------~-------~--~----~ 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 django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---