Re: middleware question

2013-05-25 Thread Marcin Szamotulski
I did some test myself and the best thing what I can do is to attach data to the request since its live cycle is what I actually need. Best regards, Marcin On 14:20 Sat 25 May , Marcin Szamotulski wrote: > Dear Django Gurus, > > I have a simple question about middleware. I have a middleware

middleware question

2013-05-25 Thread Marcin Szamotulski
Dear Django Gurus, I have a simple question about middleware. I have a middleware object which looks like this: class MyMiddleware(object): def process_view(...): ... self.data = some data ... def process_template_response(...): data = self.d

Re: middleware question

2010-04-20 Thread Peter Landry
That will add a header to the http response, not an element to the text of the xml output. There may be an easier way to do what you want with a middleware, but the only thing I can think of is to basically prepend your desired xml header to the response text and create a new HttpResponse with that

middleware question

2010-04-20 Thread Tim Arnold
Hi, I want to serve some raw xml files, but add a stylesheet to the response so the user can view it better. The raw xml begins like this: http://docbook.org/ns/docbook"; version="5.0"> etc. I want to create some middleware to serve them like this: http://docbook.org/ns/docbook"; version

Re: Django custom middleware question

2008-06-25 Thread csmith
Hey guys, thanks for the help. I actually got it working like this: class AliasMiddleware(object): def process_request(self, request): assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES

Re: Django custom middleware question

2008-06-25 Thread Alex Ezell
On Tue, Jun 24, 2008 at 11:14 PM, csmith <[EMAIL PROTECTED]> wrote: > > How can I add an attribute or variable? to the request object in > middleware, where I can use it in other views via the request object. > This is my custom middleware code so far: > > class AliasMiddleware(object): >def p

Re: Django custom middleware question

2008-06-25 Thread Alex Slesarev
> How can I add an attribute or variable? to the request object in > middleware, where I can use it in other views via the request object. You can use threading.local() variables, like this: import threading _thread_locals = threading.local() def get_current_user(): return getattr(_thr

Django custom middleware question

2008-06-24 Thread csmith
How can I add an attribute or variable? to the request object in middleware, where I can use it in other views via the request object. This is my custom middleware code so far: class AliasMiddleware(object): def process_request(self, request): assert hasattr(request, 'session'), "The

Re: middleware question

2008-04-02 Thread Russell Keith-Magee
On 4/3/08, Chris <[EMAIL PROTECTED]> wrote: > > Can anyone help me with this? It looks like I need to pass in a > django_content_type= to the request context > before it gets passed to the middleware for further processing. Any > thoughts? Yes. I think you need to wait more than 30 minutes be

Re: middleware question

2008-04-02 Thread Chris
Can anyone help me with this? It looks like I need to pass in a django_content_type= to the request context before it gets passed to the middleware for further processing. Any thoughts? On Apr 2, 3:37 pm, Chris <[EMAIL PROTECTED]> wrote: > Is there a way to grab content_type and object_id in a mi

middleware question

2008-04-02 Thread Chris
Is there a way to grab content_type and object_id in a middleware processor? Example if I went to my articles section: http://www.xyz.com/articles// could I some how get the content_type and the object_id from the request context that is passed in? I want to be able to perform a middleware task bu

Re: View (maybe middleware?) question

2007-05-31 Thread Chris Kelly
hmm, yeah, that's about what I am looking for (the site lang approach). I'll look into that some more. For this particular app, there are no stored user profiles (e.g. there is no logging in), so as much as I'd like to store this setting in a user profile, and requiring login, I can't guarantee t

Re: View (maybe middleware?) question

2007-05-30 Thread orestis
I've done something similar to this, putting the site language in the url. Basically you create a middleware process_request, that will take request.path and set it to something else. For example you might do: request.path = "/app/theme/view/" parts = request.path.split("/") request.path = "/

Re: View (maybe middleware?) question

2007-05-30 Thread Robert Coup
Chris Kelly wrote: > I am in the process of writing an app that will have a "theme" based > on if a subdirectory is specified e.g.: > > http://somesite.com/app/(theme)/abunchofviews/ > > basically, if they go to /app/bluetheme/register, it'll give them a > registration page with a blue theme heade

View (maybe middleware?) question

2007-05-30 Thread Chris Kelly
I am in the process of writing an app that will have a "theme" based on if a subdirectory is specified e.g.: http://somesite.com/app/(theme)/abunchofviews/ basically, if they go to /app/bluetheme/register, it'll give them a registration page with a blue theme header and footer (it looks up a th