django-middleware

Django url configuration for DRYness

Hi All, Most views in my project accept an optional username parameter and if exists, filter the querysets passed to the templates for that user. So, for example: the index view handles both the following url patterns: '^$' # general index page '^(?P<username>[-\w]+)/$' # index page for the user '^photos/$' # photo index page '^(?P<u...

How do I do a Rails style before_filter with Google App Engine?

The app is setup as a basic WSGI application. I'm just trying to call a function before the requestHandler is run. I would like something very much like the way before_filter works in Rails. Thanks. ...

AttributeError: 'WSGIRequest' object has no attribute 'session'

Hello, I keep getting this error at random times and whenever I touch the django.wsgi file, it gets fixed only to happen again after a few hours. I'm lost as to what to do. my middleware_classes is as follows: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', ...

Does Django message middleware not work with app engine?

Hi All, I am trying to implement the message middleware in my Django App engine project but its giving the an error message like: ImproperlyConfigured: Error importing middleware mediautils.middleware: "No module named messages" I have followed the link http://djangoadvent.com/1.2/messages-rest-us/ to implement it. Is it not possibl...

Safe to modify settings.SITE_ID from middleware in Django?

I have modified the multihost.py middleware I found at http://effbot.org/zone/django-multihost.htm to set the settings.SITE_ID dynamically, but have some concerns that I may have just left the reservation. Most examples I have found for multiple domain hosting have been setup with multiple settings.py files hardcoded to their respective...

Django - using sqlalchemy with a read-only database

I'm using Django to nicely display stats etc from an Oracle database that I only have/want read access to. Because the database has composite primary keys I'm not using Django's ORM layer and I'm using SQLAlchemy instead. The only installed apps I have are my own, and of the MIDDLEWARE_CLASSES I'm only using CommonMiddleware. Based on t...

django middleware redirect infinite loop

I have a middleware that checks a session value and redirects depending that value. My problem is, it is creating an infinite redirect loop and I'm not sure why. So, what I want to do is check to see if the value of the session visible is yes and if not redirect the user to my test view. Here is my middleware: class CheckStatus(ob...

Excluding a Django app from being localized using a middleware

I need to localize a django project, but keep one of the applications (the blog) English only. I wrote this middleware in order to achieve this: from django.conf import settings from django.core.urlresolvers import resolve class DelocalizeMiddleware: def process_request(self, request): current_app_name = __name__.split('.'...

How Do Search Engines See A Localized Django Site?

I have a Django site that uses the localization middleware in combination with gettext and the trans/blocktrans template tags to show visitors different pages depending on the preferred language in their user agent string (which seems to be the standard way of doing things in Django). This works great for supported languages (currently ...

Django: Error: ImproperlyConfigured Module does not define a " " class

ImproperlyConfigured: Middleware module "report" does not define a "ReportMiddleware" class But I had defined this, but probably defined in wrong place, so where should I place this class file? ...