On Thu, 2007-06-07 at 19:07 -0500, Adrian Holovaty wrote: > On 5/28/07, Marty Alchin <[EMAIL PROTECTED]> wrote: > > For my policy work, I'd like to be able to add in a separate URL > > handler within each model's registration, so that something like > > /admin/app/policy/ and /admin/app/model/policy/ would give editors > > customized for that location. However, I'm not seeing a way to do > > anything like that, as the URL components are all hard-coded in an > > if/elif block. > > I'm running into this problem/limitation in trying to fix > http://code.djangoproject.com/ticket/4450 -- the previous (trunk) > admin overrides the admin URLconf value for "/auth/user/" as a special > case, and newforms-admin doesn't do that yet. So there needs to be a > hook in ModelAdmin for overriding the URL parsing behavior. > > It's currently implemented in ModelAdmin.__call__(), but that method > does some other things that you shouldn't have to duplicate. So, maybe > this could be fixed by adding a small hook in there -- handle_url(), > or something. Any thoughts?
That would work. Alternatively (and I suspect this is a variation on what Marty is suggesting), move all the url processing bit out of __call__() and into a function that __call__ calls. Then that function can be overridden in the subclass. Notice that you don't have a similar problem in AdminSite because the root() method there is only doing URL processing, so it can be overridden and called via super(). I don't have any really strong preference for one method or the other, although I probably have a slight preference for the sub-classing approach if possible. We use both methods (super() calls and hooks) elsewhere in the code, so neither approach is going to be surprising, although I'm not sure if we use hooks in the public API as much. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---