From: Łukasz Rekucki Date: Fri, 4 Jun 2010 19:15:38 +0000 (+0200) Subject: VStorage now looks for if it couldn't find .xml X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/7100b7600042ac22687fb3036547841578b7e512 VStorage now looks for if it couldn't find .xml --- diff --git a/apps/wiki/models.py b/apps/wiki/models.py index d2b74605..acad2c3d 100644 --- a/apps/wiki/models.py +++ b/apps/wiki/models.py @@ -15,12 +15,13 @@ from django.http import Http404 import logging logger = logging.getLogger("fnp.wiki") -_PCHARS_DICT = dict(zip((ord(x) for x in u"ĄĆĘŁŃÓŚŻŹąćęłńóśżź "), u"ACELNOSZZacelnoszz_")) + +# _PCHARS_DICT = dict(zip((ord(x) for x in u"ĄĆĘŁŃÓŚŻŹąćęłńóśżź "), u"ACELNOSZZacelnoszz_")) +_PCHARS_DICT = dict(zip((ord(x) for x in u" "), u"_")) # I know this is barbaric, but I didn't find a better solution ;( def split_name(name): parts = name.translate(_PCHARS_DICT).split('__') - logger.info("SPLIT %r -> %r", name, parts) return parts def join_name(*parts, **kwargs): diff --git a/apps/wiki/templates/wiki/tabs/history_view.html b/apps/wiki/templates/wiki/tabs/history_view.html index 5e385ab2..9f68dc49 100644 --- a/apps/wiki/templates/wiki/tabs/history_view.html +++ b/apps/wiki/templates/wiki/tabs/history_view.html @@ -4,7 +4,7 @@ + data-basehref="{% url wiki_editor_readonly document_name %}">{% trans "View version" %}
diff --git a/apps/wiki/templatetags/wiki.py b/apps/wiki/templatetags/wiki.py index 614858df..cb5bf20c 100644 --- a/apps/wiki/templatetags/wiki.py +++ b/apps/wiki/templatetags/wiki.py @@ -5,7 +5,7 @@ from django import template register = template.Library() -# from wiki.models import split_name +from wiki.models import split_name @register.filter @stringfilter diff --git a/deployment.py b/deployment.py index 041b58cc..3553aa18 100644 --- a/deployment.py +++ b/deployment.py @@ -29,13 +29,12 @@ def update_application(): os.system("pip install -r %s" % os.path.join(ROOT, 'etc', 'requirements.txt')) print "done." -ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PYTHON = os.path.join(ROOT, 'pythonenv', 'bin', 'python') PYTHON_SITE = os.path.join(ROOT, 'pythonenv', 'lib', 'python2.6', 'site-packages') PROJECT_NAME = 'redakcja' -PROJECT_ROOT = os.path.join(ROOT, 'app') +PROJECT_ROOT = os.path.join(ROOT, 'application') MEDIA_ROOT = os.path.join(ROOT, 'www', 'media') diff --git a/lib/vstorage/__init__.py b/lib/vstorage/__init__.py index aeb7338a..9f7084b3 100644 --- a/lib/vstorage/__init__.py +++ b/lib/vstorage/__init__.py @@ -326,33 +326,40 @@ class VersionedStorage(object): def _find_filectx(self, title, rev=None): """Find the last revision in which the file existed.""" - repo_file = self._title_to_file(title) - changectx = self._changectx() # start with tip - visited = set() + tip = self._changectx() # start with tip - stack = [changectx] - visited.add(changectx) + def tree_search(tip, repo_file): + logging.info("Searching for %r", repo_file) + current = tip + visited = set() - while repo_file not in changectx: - if not stack: - raise DocumentNotFound(title) + stack = [current] + visited.add(current) - changectx = stack.pop() - for parent in changectx.parents(): - if parent not in visited: - stack.append(parent) - visited.add(parent) + while repo_file not in current: + if not stack: + raise LookupError - try: - fctx = changectx[repo_file] + current = stack.pop() + for parent in current.parents(): + if parent not in visited: + stack.append(parent) + visited.add(parent) + fctx = current[repo_file] if rev is not None: fctx = fctx.filectx(rev) fctx.filerev() - return fctx + + try: + return tree_search(tip, self._title_to_file(title)) except (IndexError, LookupError) as e: - raise DocumentNotFound(title) + logging.info("XML file not found, trying plain") + try: + return tree_search(tip, self._title_to_file(title, type='')) + except (IndexError, LookupError) as e: + raise DocumentNotFound(title) def page_history(self, title): """Iterate over the page's history.""" diff --git a/redakcja/settings/common.py b/redakcja/settings/common.py index 379f5b59..377a4d50 100644 --- a/redakcja/settings/common.py +++ b/redakcja/settings/common.py @@ -141,6 +141,8 @@ WL_API_CONFIG = { # Import localsettings file, which may override settings defined here +from localsettings import * + try: import logging if os.path.isfile(LOGGING_CONFIG_FILE): @@ -149,8 +151,5 @@ try: else: import sys logging.basicConfig(stream=sys.stderr) -except NameError: - print "No logging" - pass except ImportError as exc: raise