From 54e3b77e2346618a6e7cd0fe8beb71e7b54a30e6 Mon Sep 17 00:00:00 2001 From: zuber Date: Fri, 27 Nov 2009 15:40:49 +0100 Subject: [PATCH] Dodanie aplikacji wiki. --- apps/wiki/__init__.py | 0 apps/wiki/models.py | 31 +++++++++++++++++++++++++++++++ apps/wiki/settings.py | 6 ++++++ apps/wiki/tests.py | 0 4 files changed, 37 insertions(+) create mode 100644 apps/wiki/__init__.py create mode 100644 apps/wiki/models.py create mode 100644 apps/wiki/settings.py create mode 100644 apps/wiki/tests.py diff --git a/apps/wiki/__init__.py b/apps/wiki/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/wiki/models.py b/apps/wiki/models.py new file mode 100644 index 00000000..a1281334 --- /dev/null +++ b/apps/wiki/models.py @@ -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 index 00000000..87b03300 --- /dev/null +++ b/apps/wiki/settings.py @@ -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 index 00000000..e69de29b -- 2.20.1