On Sat, Sep 12, 2009 at 8:42 AM, Thomas K. Adamcik <tadam...@gmail.com> wrote: > In essence we could add only one new method to the API that returns a > URL-object that provides access to the data:
I like this idea a lot. It solves most of the problems I have with get_absolute_url: * I dislike the name -- far too verbose. Why not just `obj.url()`? * I wish there was a better mechanism for getting host-relative URLs, schema-relative URLs, etc. The `<a href="//...">` trick is annoyingly obscure. * The mismatch between `...@models.permalink` and `get_absolute_url` is very counter-intuitive. * The fact that the returned URL is a string often means I end up doing something like `obj.get_absolute_url().split('/')`. Objects are better. > If reverse() and {% url %} methods are updated to use such an URL-object > backwards-compatibility can probably be persevered through a proper __str__ > method on the URL-object. Python's already got such an object; it's `urlparse.ParseResult` (the object returned by `urlparse.urlparse`. We'd need a tiny subclass with a backwards-compatible `__str__`, but that's about it. > I have not double checked if all the issues mentioned in > http://code.djangoproject.com/wiki/ReplacingGetAbsoluteUrl can be solved with > such a scheme, but if there is interest in such a solution I'm willing to look > into this and trying out the idea either as an external project or as a patch > proposal. I'm +1 on this proposal; please ping me if you work up a patch and I'll take a look. Jacob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---