Changeset 886
- Timestamp:
- 10/16/05 11:17:48 (3 years ago)
- Files:
-
- django/branches/i18n/django/conf/global_settings.py (modified) (1 diff)
- django/branches/i18n/django/conf/project_template/settings/main.py (modified) (1 diff)
- django/branches/i18n/django/core/db/backends/ado_mssql.py (added)
- django/branches/i18n/django/core/handlers/base.py (modified) (4 diffs)
- django/branches/i18n/django/core/meta/__init__.py (modified) (1 diff)
- django/branches/i18n/django/utils/decorators.py (modified) (1 diff)
- django/branches/i18n/docs/middleware.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/conf/global_settings.py
r874 r886 56 56 57 57 # Database connection info. 58 DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', or 'sqlite3'.59 DATABASE_NAME = '' 60 DATABASE_USER = '' 61 DATABASE_PASSWORD = '' 62 DATABASE_HOST = '' # Set to empty string for localhost. 63 DATABASE_PORT = '' # Set to empty string for default. 58 DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. 59 DATABASE_NAME = '' # Or path to database file if using sqlite3. 60 DATABASE_USER = '' # Not used with sqlite3. 61 DATABASE_PASSWORD = '' # Not used with sqlite3. 62 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. 63 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 64 64 65 65 # Host for sending e-mail. django/branches/i18n/django/conf/project_template/settings/main.py
r869 r886 11 11 LANGUAGE_CODE = 'en-us' 12 12 13 DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', or 'sqlite3'.13 DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'. 14 14 DATABASE_NAME = '' # Or path to database file if using sqlite3. 15 15 DATABASE_USER = '' # Not used with sqlite3. django/branches/i18n/django/core/handlers/base.py
r580 r886 3 3 class BaseHandler: 4 4 def __init__(self): 5 self._request_middleware = self._view_middleware = self._response_middleware = None5 self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None 6 6 7 7 def load_middleware(self): … … 16 16 self._view_middleware = [] 17 17 self._response_middleware = [] 18 self._exception_middleware = [] 18 19 for middleware_path in settings.MIDDLEWARE_CLASSES: 19 20 dot = middleware_path.rindex('.') … … 39 40 if hasattr(mw_instance, 'process_response'): 40 41 self._response_middleware.insert(0, mw_instance.process_response) 42 if hasattr(mw_instance, 'process_exception'): 43 self._exception_middleware.insert(0, mw_instance.process_exception) 41 44 42 45 def get_response(self, path, request): … … 62 65 return response 63 66 64 response = callback(request, **param_dict) 67 try: 68 response = callback(request, **param_dict) 69 except Exception, e: 70 # If the view raised an exception, run it through exception 71 # middleware, and if the exception middleware returns a 72 # response, use that. Otherwise, reraise the exception. 73 for middleware_method in self._exception_middleware: 74 response = middleware_method(request, e) 75 if response: 76 return response 77 raise e 65 78 66 79 # Complain if the view returned None (a common error). django/branches/i18n/django/core/meta/__init__.py
r815 r886 564 564 565 565 # Give the class a docstring -- its definition. 566 new_class.__doc__ = "%s.%s(%s)" % (opts.module_name, name, ", ".join([f.name for f in opts.fields])) 566 if new_class.__doc__ is None: 567 new_class.__doc__ = "%s.%s(%s)" % (opts.module_name, name, ", ".join([f.name for f in opts.fields])) 567 568 568 569 # Create the standard, module-level API helper functions such django/branches/i18n/django/utils/decorators.py
r844 r886 17 17 if result is not None: 18 18 return result 19 response = view_func(request, *args, **kwargs) 19 try: 20 response = view_func(request, *args, **kwargs) 21 except Exception, e: 22 if hasattr(middleware, 'process_exception'): 23 result = middleware.process_exception(request, e) 24 if result is not None: 25 return result 26 raise e 20 27 if hasattr(middleware, 'process_response'): 21 28 result = middleware.process_response(request, response) django/branches/i18n/docs/middleware.txt
r815 r886 169 169 ``HttpResponse``. 170 170 171 process_exception 172 ----------------- 173 174 Interface: ``process_exception(self, request, exception)`` 175 176 ``request`` is an ``HttpRequest`` object. ``exception`` is an ``Exception`` 177 object raised by the view function. 178 179 Django calls ``process_exception()`` when a view raises an exception. 180 ``process_exception()`` should return either ``None`` or an ``HttpResponse`` 181 object. If it returns an ``HttpResponse`` object, the response will be returned 182 to the browser. Otherwise, default exception handling kicks in. 183 171 184 Guidelines 172 185 ----------
