From: Ɓukasz Rekucki Date: Fri, 2 Oct 2009 11:05:36 +0000 (+0200) Subject: Hope i fixed the stange - "not found" annomaly. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/09c2bec530540e51e71822a8269bb994cc144065?ds=sidebyside;hp=-c Hope i fixed the stange - "not found" annomaly. --- 09c2bec530540e51e71822a8269bb994cc144065 diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index 93d650bb..c5c52564 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -177,13 +177,14 @@ class DocumentHandler(BaseHandler): @hglibrary def read(self, request, docid, lib): """Read document's meta data""" - log.info("Read %s", docid) + log.info(u"Read %s (%s)" % (docid, type(docid)) ) try: doc = lib.document(docid) udoc = doc.take(request.user.username) except RevisionNotFound, e: return response.EntityNotFound().django_response({ - 'exception': type(e), 'message': e.message}) + 'exception': type(e), 'message': e.message, + 'docid': docid }) # is_shared = udoc.ancestorof(doc) # is_uptodate = is_shared or shared.ancestorof(document) diff --git a/lib/wlrepo/mercurial_backend/__init__.py b/lib/wlrepo/mercurial_backend/__init__.py index a22e49f1..f919e817 100644 --- a/lib/wlrepo/mercurial_backend/__init__.py +++ b/lib/wlrepo/mercurial_backend/__init__.py @@ -7,6 +7,9 @@ __doc__ = "Module documentation." import wlrepo from mercurial.node import nullid +from mercurial import encoding +encoding.encoding = 'utf-8' + class MercurialRevision(wlrepo.Revision): def __init__(self, lib, changectx): diff --git a/lib/wlrepo/mercurial_backend/library.py b/lib/wlrepo/mercurial_backend/library.py index f033fce0..8c57f038 100644 --- a/lib/wlrepo/mercurial_backend/library.py +++ b/lib/wlrepo/mercurial_backend/library.py @@ -96,10 +96,16 @@ class MercurialLibrary(wlrepo.Library): return self.document_for_rev(self.fulldocid(docid, user)) def get_revision(self, revid): - revid = self._sanitize_string(revid) + revid = self._sanitize_string(revid).decode('utf-8') + + print "Looking up rev %r (%s)" %(revid, type(revid)) try: - ctx = self._changectx(revid) + # THIS IS THE MOST BRAIN-DEAD API I EVER SEEN + # WHY DO ALL THE OTHER METHODS SIMPLY + # FAIL WHEN GIVEN UNICODE, WHEN THIS WORKS ONLY!! WITH IT + + ctx = self._changectx( revid.decode('utf-8') ) except mercurial.error.RepoError, e: raise wlrepo.RevisionNotFound(revid) @@ -118,7 +124,6 @@ class MercurialLibrary(wlrepo.Library): fulldocid += u'$doc:' + docid return fulldocid - def has_revision(self, revid): try: self._hgrepo[revid] diff --git a/project/static/js/models.js b/project/static/js/models.js index b32f192e..5c6b36d4 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -6,8 +6,7 @@ Editor.Model = Editor.Object.extend({ Editor.ToolbarButtonsModel = Editor.Model.extend({ - className: 'Editor.ToolbarButtonsModel', - serverURL: '/api/toolbar/buttons', + className: 'Editor.ToolbarButtonsModel', buttons: {}, init: function() { @@ -17,7 +16,7 @@ Editor.ToolbarButtonsModel = Editor.Model.extend({ load: function() { if (!this.get('buttons').length) { $.ajax({ - url: this.serverURL, + url: toolbarUrl, dataType: 'json', success: this.loadSucceeded.bind(this) }); @@ -404,7 +403,7 @@ var leftPanelView, rightPanelContainer, doc; $(function() { documentsUrl = $('#api-base-url').text() + '/'; - Editor.ToolbarButtonsModel.serverURL = $('#api-toolbar-url').text(); + toolbarUrl = $('#api-toolbar-url').text(); doc = new Editor.DocumentModel(); var editor = new EditorView('#body-wrap', doc);