On 4 mai 09, at 23:36, Malcolm Tredinnick <malc...@pointy-stick.com>  
wrote:
> On Mon, 2009-05-04 at 15:41 +0200, Masklinn wrote:
>> On 4 May 2009, at 14:55 , pbzRPA wrote:
>>> On May 4, 1:24 pm, Masklinn <maskl...@masklinn.net> wrote:
>
> [...]
>
>>>> FWIW the `'app.views.showItems'` isn't even necessary, you can just
>>>> pass the view function and reverse will figure out the rest, so
>>>>
>>>>     return HttpResponseRedirect(reverse(showItems))
>>>>
>>>> is, in fact, sufficient.
>
>>>
>>> That is correct but only if the function resides in the same file  
>>> that
>>> the reverse function is used.
>
>> Unless you import it yes, but in this case the function *does* reside
>> in the same file.
>
> It's still a little fragile to use function references in reverse()
> calls. It works in many situations, but not always. This is because  
> the
> reference you pass in has to be exactly the same reference that the  
> URL
> Conf file has -- and that's only true if they were imported using the
> same path (and how the URL Conf file does the import isn't entirely
> under your control).
>
> Best practice here really has to be providing a name to each URL
> pattern. It's easy to read, easy to debug and works 100% of the time.
> Function references are useful in URL conf files, but they aren't the
> friend of reverse() and there's not a lot we can do about that  
> (because
> that's how Python works).
>
> Regards,
> Malcolm
>
Sorry for the previous mail, misstap.

Anyway thanks for the info, I'll stop suggesting that if there's  
breakage risk, and I'll remember it in case strange things happen in  
my code.

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to