Re: middleware introspection

2007-10-05 Thread Jeremy Dunck

On 10/5/07, Robin Becker <[EMAIL PROTECTED]> wrote:
> can the middleware determine the template used by V0 so that it can be used
> automatically to generate V2?

Yes.  Have a look at django.test.utils.instrumented_test_render and
.setup_test_environment.
You'll see a way to monkeypatch Template.render to make a signal fire
when templates are rendered.

You can have your middleware initialize a list on the request object
before V0 is called (process_request), add templates to the list when
the signal is fired, then do something based on which templates were
used (process_response).

If you find that signal useful, it may be that such a real-world
requirement would drive django.test.signals.template_rendered to be
changed to always fire rather than just when monkeypatched by
django.test.  :)

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



middleware introspection

2007-10-05 Thread Robin Becker

A colleague is writing a response middleware which hijacks the normal view 
under 
certain circumstances. Diagramatically


V0  -->M(0)--> V1  is the normal case view V0 goes directly  to V1 ie the 
middleware M does nothing.

when the hijack is to take place

V0 -->M(1)-->V2-->M(0)-->V1

Now my question

can the middleware determine the template used by V0 so that it can be used 
automatically to generate V2?
-- 
Robin Becker

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---