On Tue, 2007-12-18 at 02:40 -0800, frank h. wrote:
> hello,
> in a contextprocessor i am writing, i would like to use the "named
> url" of the current view instead of request.path.
>
> I toyd with django.core.urlresolvers.resolve() but that just returns
> the function configured in urls.py and not the name it was configured
> with
>
> to give an example: my urls.py contains this pattern
>
> urlpatterns += patterns('mcc.log.status',
> url(r'ftpqueue/$', 'ftpqueue', name='mcc-ftpqueue'),
> )
>
>
> in my contextprocessor, request.path is '/ftpqueue/'
> now I want to get to the name: 'mcc-ftpqueue'
>
> how to do that?
There's not built in way to do this.
If you really wanted to do this in an automated way, you would need to
write something like the current URL resolving code that ran through the
patterns until it found a match (following include() calls as well) and
then returned the pattern name. Not impossible and you could probably
follow the code in urlresolvers.py initially, but not something that
you'll get just by calling a single function in core().
Regards,
Malcolm
--
Quantum mechanics: the dreams stuff is made of.
http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---