Dodanie aplikacji wiki.
[redakcja.git] / apps / wiki / models.py
1 import vstorage
2 from wiki import settings
3
4
5 class DocumentStorage(object):
6     def __init__(self, path):
7         self.vstorage = vstorage.VersionedStorage(path)
8     
9     def get(self, name, revision=None):
10         if revision is None:
11             text = self.vstorage.page_text(name)
12         else:
13             text = self.vstorage.revision_text(name, revision)
14         return Document(self, name=name, text=text)
15     
16     def put(self, name, document, author, comment, parent):
17         self.vstorage.save_text(document.name, document.text, author, comment, parent)
18
19     def delete(name, author, comment):
20         self.vstorage.delete_page(name, author, comment)
21
22
23 class Document(object):
24     def __init__(self, storage, **kwargs):
25         self.storage = storage
26         for attr, value in kwargs:
27             setattr(self, attr, value)
28
29
30 storage = DocumentStorage(settings.REPOSITORY_PATH)
31