From: zuber Date: Fri, 27 Nov 2009 14:40:49 +0000 (+0100) Subject: Dodanie aplikacji wiki. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/54e3b77e2346618a6e7cd0fe8beb71e7b54a30e6?ds=sidebyside;hp=3eec01e4c2a842c7383857e49d68664f04759c1f Dodanie aplikacji wiki. --- 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