On 26 août, 17:30, Uwe Schuerkamp <uwe.schuerk...@gmail.com> wrote:
>
> Hello Bruno,
>
> thanks for your answer. I'm already using a custom context_processor
> (yay! ;-), so I'll follow that suggestion, too. I've tried wrapping my
> head around the process_view function, but I'm not exactly clear on
> how it works just yet.

Well, middleware.process_view is rather clearly documented. What do
you have problems with exactly ?

> So juet for laffs, I wrote my first custom
> template tag (another yay! ;-) and it does the job nicely:
>
(snip)
>
> register.simple_tag(pathfinder)

You cheated !-) You should have wrote a full blown tag with the parser
and node !-)


> so now in my navigation bar (actually it's just a table <td>), I can
> employ the following syntax:
>
>  <a href="{% pathfinder request %}{% url club300.views.observation_add
> %}">add observation</a><br>

{% url %} - or the python function it's based on, namely
urlresolvers.reverse - can build the proper url (reverse of the url
resolving part) given the appropriate arguments.


> Storing the data in the request object also seems like a great idea,

FWIW you could just pass the needed view function's arguments to the
context from within the view function itself, but that means you have
to do so in all your views. Using a middleware + templatetag might
prove more generic, even if more involved.

Duh... Just crossed my mind that you could also use a simple decorator
to store the relevant infos on the request object. And that's
something you can do in your urls (wrapping the view function in the
decorator within the urlpattern itself).

> I'll certainly look into that! Of course you're right about having to
> change two spots in case I ever decide to redesign my URL's, so a
> refactoring is in order!

Case of "first make it work" (ok, done) "then make it right" !-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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