Dodanie aplikacji wiki.
authorzuber <marek@stepniowski.com>
Fri, 27 Nov 2009 14:40:49 +0000 (15:40 +0100)
committerzuber <marek@stepniowski.com>
Fri, 27 Nov 2009 14:40:49 +0000 (15:40 +0100)
apps/wiki/__init__.py [new file with mode: 0644]
apps/wiki/models.py [new file with mode: 0644]
apps/wiki/settings.py [new file with mode: 0644]
apps/wiki/tests.py [new file with mode: 0644]

diff --git a/apps/wiki/__init__.py b/apps/wiki/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/apps/wiki/models.py b/apps/wiki/models.py
new file mode 100644 (file)
index 0000000..a128133
--- /dev/null
@@ -0,0 +1,31 @@
+import vstorage
+from wiki import settings
+
+
+class DocumentStorage(object):
+    def __init__(self, path):
+        self.vstorage = vstorage.VersionedStorage(path)
+    
+    def get(self, name, revision=None):
+        if revision is None:
+            text = self.vstorage.page_text(name)
+        else:
+            text = self.vstorage.revision_text(name, revision)
+        return Document(self, name=name, text=text)
+    
+    def put(self, name, document, author, comment, parent):
+        self.vstorage.save_text(document.name, document.text, author, comment, parent)
+
+    def delete(name, author, comment):
+        self.vstorage.delete_page(name, author, comment)
+
+
+class Document(object):
+    def __init__(self, storage, **kwargs):
+        self.storage = storage
+        for attr, value in kwargs:
+            setattr(self, attr, value)
+
+
+storage = DocumentStorage(settings.REPOSITORY_PATH)
+
diff --git a/apps/wiki/settings.py b/apps/wiki/settings.py
new file mode 100644 (file)
index 0000000..87b0330
--- /dev/null
@@ -0,0 +1,6 @@
+from django.conf import settings
+
+if not hasattr(settings, 'WIKI_REPOSITORY_PATH'):
+    raise Exception('You must set WIKI_REPOSITORY_PATH in your settings file.')
+
+REPOSITORY_PATH = settings.WIKI_REPOSITORY_PATH
diff --git a/apps/wiki/tests.py b/apps/wiki/tests.py
new file mode 100644 (file)
index 0000000..e69de29