Ticket #730: mw-depends.diff
File mw-depends.diff, 3.6 KB (added by , 16 years ago) |
---|
-
django/core/management/validation.py
28 28 for (app_name, error) in get_app_errors().items(): 29 29 e.add(app_name, error) 30 30 31 # Check middleware ordering 32 mw_seen = [] 33 for middleware_path in settings.MIDDLEWARE_CLASSES: 34 try: 35 dot = middleware_path.rindex('.') 36 except ValueError: 37 continue # not middleware 38 mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:] 39 try: 40 mod = __import__(mw_module, {}, {}, ['']) 41 except ImportError, e: 42 continue 43 try: 44 mw_class = getattr(mod, mw_classname) 45 except AttributeError: 46 continue # classname not found 47 try: 48 mw_instance = mw_class() 49 except exceptions.MiddlewareNotUsed: 50 continue 51 mw_seen.append(middleware_path) 52 if hasattr(mw_instance, 'depends') and mw_instance.depends: 53 for dep in mw_instance.depends: 54 if dep not in mw_seen: 55 e.add(middleware_path, 'Dependency on "%s" not met. Check to make sure the dependent middleware is included in MIDDLEWARE_CLASSES and is listed above %s.' % (dep, mw_classname)) 56 31 57 for cls in models.get_models(app): 32 58 opts = cls._meta 33 59 -
django/contrib/auth/middleware.py
6 6 return request._cached_user 7 7 8 8 class AuthenticationMiddleware(object): 9 10 depends = ('django.contrib.sessions.middleware.SessionMiddleware',) 11 9 12 def process_request(self, request): 10 13 assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." 11 14 request.__class__.user = LazyUser() -
django/contrib/sessions/middleware.py
9 9 10 10 class SessionMiddleware(object): 11 11 12 depends = () 13 12 14 def process_request(self, request): 13 15 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 14 16 session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) -
django/middleware/common.py
28 28 appropriately. 29 29 """ 30 30 31 depends = () 32 31 33 def process_request(self, request): 32 34 """ 33 35 Check for denied User-Agents and rewrite the URL based on -
django/middleware/doc.py
5 5 """ 6 6 Adds an X-View header to internal HEAD requests -- used by the documentation system. 7 7 """ 8 9 depends = ('django.contrib.auth.middleware.AuthenticationMiddleware',) 10 8 11 def process_view(self, request, view_func, view_args, view_kwargs): 9 12 """ 10 13 If the request method is HEAD and either the IP is internal or the