> This does hint that you're using the wrong shovel to hammer in your > screws, however. You've said that you want to change that URL, always. > Hence it's in ABSOLUTE_URL_OVERRIDES. Later you are effectively saying > "no, just joking... I don't want it overridden all the time". If it's > only meant to be changed sometimes, the ABSOLUTE_URL_OVERRIDES is not > the right tool for the job.
Exactly: I want to override it sometimes and then sometimes I don't want to override it. The same thing is done in OOP inheritance all the time using conditional superclass method calls. You're probably right about ABSOLUTE_URL_OVERRIDES not being the right tool for the job, but I didn't figure out any other ways of achieving the same effect. > What is the real problem you are trying to solve? I'm writing a content management framework which stores content in a tree of nodes. Nodes can be of different content types and I want to be able to add new content types by simply adding apps that provide models to INSTALLED_APPS. And I don't want these apps to be forced to be aware of the existence of my content framework. Anyway, apps normally define URLs/views for models, and that means I won't be able to pull these models into my own URL hierarchy. So for that reason I need to be able to override URLs of other apps' models. And here comes the problem I'm trying to solve: to be able to override a models URL, I still need to know which view/args/kwargs it maps to so I need to take the model's original URL, resolve it using the model's containing app's URLconf, and then dynamically create a URL pattern for the view/args/kwargs that the model's original URL resolved to. But, by the time my custom URL resolver kicks in, the ABSOLUTE_URL_OVERRIDES setting has already taken effect and there's no way to find out which view/args/kwargs a model maps to any more. So right now I've added a single line to Django source code before cls.get_absolute_url = curry(get_absolute_url, ...) that says cls.old_get_absolute_url = cls.get_absolute_url. That's it. I was just hoping there's a way of doing it without patching Django, such as getting my hands on the model's methods BEFORE ModelBase._prepare is called (in which the overriding is done). And another, slightly less important problem is that I want any model instances that aren't bound to my own URL hierarchy still map to their original URLs, but again, I can't really know the original URL once get_absolute_url is overwritten. Erik --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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-users?hl=en -~----------~----~----~----~------~----~------~--~---