On Apr 19, 3:12 pm, Shawn Milochik <sh...@milochik.com> wrote:
> You can create your own middleware.
>
> http://docs.djangoproject.com/en/1.1/topics/http/middleware/
>
> Shawn
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

Thanks, that looks exactly like what I need. I've got this so far.
Additional details: the file I'm serving is actually xml, and I want
to always have it rendered using a special css stylesheet:
----------- middleware.py -------------
css = '/media/css/XSL/driver.css'

class XMLMiddleware(object):
    def process_response(self, request, response):
        if request.path.endswith('.xml'):
            response['xml-stylesheet'] = css
        return response

I'm not sure about that code yet (i.e, not tested) but what I want the
file to look like when it gets to the browser is this:
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="/media/css/XSL/driver.css" ?>
<chapter xmlns="http://docbook.org/ns/docbook"; version="5.0">
etc.
</chapter>

thanks,
--Tim


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