From a8e1fae76ff2277a387f403600fe31bef4b2387e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Sat, 26 Sep 2009 11:55:16 +0200 Subject: [PATCH 1/1] Added maintance mode middleware. --- apps/api/handlers/library_handlers.py | 7 ++++- apps/api/response.py | 11 ++++++-- apps/maintenancemode/._middleware.py | Bin 0 -> 184 bytes apps/maintenancemode/__init__.py | 0 apps/maintenancemode/conf/._settings.py | Bin 0 -> 184 bytes apps/maintenancemode/conf/__init__.py | 0 apps/maintenancemode/conf/settings.py | 3 ++ apps/maintenancemode/conf/urls/__init__.py | 0 apps/maintenancemode/conf/urls/defaults.py | 3 ++ apps/maintenancemode/http.py | 4 +++ apps/maintenancemode/middleware.py | 31 +++++++++++++++++++++ apps/maintenancemode/views/__init__.py | 0 apps/maintenancemode/views/defaults.py | 16 +++++++++++ project/settings.py | 2 ++ 14 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 apps/maintenancemode/._middleware.py create mode 100644 apps/maintenancemode/__init__.py create mode 100644 apps/maintenancemode/conf/._settings.py create mode 100644 apps/maintenancemode/conf/__init__.py create mode 100644 apps/maintenancemode/conf/settings.py create mode 100644 apps/maintenancemode/conf/urls/__init__.py create mode 100644 apps/maintenancemode/conf/urls/defaults.py create mode 100644 apps/maintenancemode/http.py create mode 100644 apps/maintenancemode/middleware.py create mode 100644 apps/maintenancemode/views/__init__.py create mode 100644 apps/maintenancemode/views/defaults.py diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index 45dff83b..18dd3e81 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -35,6 +35,7 @@ class BasicLibraryHandler(AnonymousBaseHandler): 'name': docid } for docid in lib.documents() ] return {'documents' : document_list} + class LibraryHandler(BaseHandler): allowed_methods = ('GET', 'POST') @@ -48,7 +49,7 @@ class LibraryHandler(BaseHandler): 'url': reverse('document_view', args=[docid]), 'name': docid } for docid in lib.documents() ] - return {'documents' : document_list } + return {'documents' : document_list } @validate_form(forms.DocumentUploadForm, 'POST') def create(self, request, form): @@ -137,6 +138,10 @@ class DocumentHandler(BaseHandler): return result + def update(self, request, docid): + """Update information about the document, like display not""" + return + # # Document Text View # diff --git a/apps/api/response.py b/apps/api/response.py index 322118a0..6b685624 100644 --- a/apps/api/response.py +++ b/apps/api/response.py @@ -22,7 +22,7 @@ class ResponseObject(object): elif self._mime == MIME_JSON: data = json.dumps(body, default=lambda o: repr(o) ) else: - data = u"%s\n%s" % (self.MESSAGE, unicode(self._info)) + data = u"%s\n%s" % (self.MESSAGE, unicode(body)) data = data.encode('utf-8') return HttpResponse(content=data, status=self._code, \ @@ -60,7 +60,6 @@ class SuccessNoContent(ResponseObject): def django_response(self): return ResponseObject.django_response(self, body=None) - # # Client errors # @@ -96,6 +95,14 @@ class EntityConflict(ResponseObject): ResponseObject.__init__(self, 409, **kwargs) +# +# Server side errors +# +class NotImplemented(ResponseObject): + + def __init__(self, **kwargs): + ResponseObject.__init__(self, 501, **kwargs) + def validate_form(formclass, source='GET'): from functools import wraps diff --git a/apps/maintenancemode/._middleware.py b/apps/maintenancemode/._middleware.py new file mode 100644 index 0000000000000000000000000000000000000000..d25f019d631923647b9bca27402fccf9adfdf781 GIT binary patch literal 184 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}aT^eW_&b1@2;dkJ62xeG_5e^RNXHBy zRsdpTzzF0(#YL0zbM$Vqox1Ojhs@R)|o50+1L3ClDI}aT^eW_&b1@2;dkJ62xeGb~#WfNXHBy zRsdpTzzF0(#YL0zbM