Mercurial > agora-palash
view middleware/http.py @ 184:b711f0087709
Use DESCRIPTION file for bundles (SCHEMA CHANGE)
* Added two new fields to the Bundle model:
* octave_format, which allows users to specify if their bundle has
been formatted according to octave packaging standards or not
* description_file, which points to a file named DESCRIPTION in
the root directory (or the next top-level directory), if the
octave_format checkbox is ticked and if one exists
* Fixed the uploader field for form by making it a hidden input and
preventing hidden inputs from showing up entirely
author | dellsystem <ilostwaldo@gmail.com> |
---|---|
date | Sat, 27 Oct 2012 15:58:08 -0400 |
parents | 290dd9208cc4 |
children |
line wrap: on
line source
from django.template import RequestContext from django.conf import settings from django.core.exceptions import PermissionDenied from django.http import HttpResponseForbidden from django.template import loader class Http403(Exception): pass def render_to_403(*args, **kwargs): """ Returns a HttpResponseForbidden whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments. """ if not isinstance(args,list): args = [] args.append('403.html') httpresponse_kwargs = {'mimetype': kwargs.pop('mimetype', None)} response = HttpResponseForbidden(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) return response class Http403Middleware(object): def process_exception(self,request,exception): if isinstance(exception,Http403): return render_to_403(context_instance=RequestContext(request))