VStorage now looks for <doc> if it couldn't find <doc>.xml
authorŁukasz Rekucki <lrekucki@gmail.com>
Fri, 4 Jun 2010 19:15:38 +0000 (21:15 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Fri, 4 Jun 2010 19:15:38 +0000 (21:15 +0200)
apps/wiki/models.py
apps/wiki/templates/wiki/tabs/history_view.html
apps/wiki/templatetags/wiki.py
deployment.py
lib/vstorage/__init__.py
redakcja/settings/common.py

index d2b7460..acad2c3 100644 (file)
@@ -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):
index 5e385ab..9f68dc4 100644 (file)
@@ -4,7 +4,7 @@
        <button type="button" id="make-diff-button">{% trans "Compare versions" %}</button>
                <button type="button" id="tag-changeset-button">{% trans "Mark version" %}</button>
                <button id="open-preview-button"
-                       data-basehref="{% url wiki_details_readonly document_name %}">{% trans "View version" %}</button>
+                       data-basehref="{% url wiki_editor_readonly document_name %}">{% trans "View version" %}</button>
 
        </div>
     <div id="history-view">
index 614858d..cb5bf20 100644 (file)
@@ -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
index 041b58c..3553aa1 100644 (file)
@@ -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')
 
index aeb7338..9f7084b 100644 (file)
@@ -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."""
index 379f5b5..377a4d5 100644 (file)
@@ -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