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
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
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
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
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
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
> 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
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
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
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
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
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
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 = "/
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
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
15 matches
Mail list logo