From: Ɓukasz Rekucki Date: Wed, 30 Sep 2009 14:40:21 +0000 (+0200) Subject: Fixed 2 bugs from GT: X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/79e71f7257f8fb8909751f968e516e9e9ee1f011 Fixed 2 bugs from GT: https://mail.google.com/mail/?zx=pyipfvus57bn&shva=1#inbox/1240b1d511c7eb96 --- diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index 39177f53..9d50d023 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -102,6 +102,9 @@ class LibraryHandler(BaseHandler): else: data = request.FILES['ocr_file'].read().decode('utf-8') + if data is None: + return response.BadRequest().django_response('You must pass ocr_data or ocr_file.') + if form.cleaned_data['generate_dc']: data = librarian.wrap_text(data, unicode(date.today())) @@ -118,9 +121,10 @@ class LibraryHandler(BaseHandler): doc = doc.quickwrite('xml', data.encode('utf-8'), '$AUTO$ XML data uploaded.', user=request.user.username) except Exception,e: + import traceback # rollback branch creation lib._rollback() - raise LibraryException("Exception occured:" + repr(e)) + raise LibraryException(traceback.format_exc()) url = reverse('document_view', args=[doc.id]) @@ -133,8 +137,9 @@ class LibraryHandler(BaseHandler): finally: lock.release() except LibraryException, e: + import traceback return response.InternalError().django_response(\ - {'exception': repr(e) }) + {'exception': traceback.format_exc()} ) except DocumentAlreadyExists: # Document is already there return response.EntityConflict().django_response(\ diff --git a/apps/api/tests/__init__.py b/apps/api/tests/__init__.py index 2044fce7..c5d79e70 100644 --- a/apps/api/tests/__init__.py +++ b/apps/api/tests/__init__.py @@ -154,7 +154,8 @@ class SimpleTest(TestCase): resp = self.assert_json_response() - self.response = self.client.put(resp['text_url'], {'contents': TEXT }) + self.response = self.client.post(resp['text_url'], { + 'revision': resp['user_revision'] ,'contents': TEXT }) result = self.assert_json_response(must_have={u'document': u'sample'} ) #self.response = self.client.get(result['url']) diff --git a/lib/wlrepo/mercurial_backend/__init__.py b/lib/wlrepo/mercurial_backend/__init__.py index 8b5849cc..a22e49f1 100644 --- a/lib/wlrepo/mercurial_backend/__init__.py +++ b/lib/wlrepo/mercurial_backend/__init__.py @@ -28,11 +28,11 @@ class MercurialRevision(wlrepo.Revision): @property def document_name(self): - return self._docname.decode('utf-8') + return self._docname and self._docname.decode('utf-8') @property def user_name(self): - return self._username.decode('utf-8') + return self._username and self._username.decode('utf-8') def hgrev(self): return self._changectx.node()