# Netbeans garbage
nbproject
-nbproject/*
\ No newline at end of file
+nbproject/*
+
+# Eclipse
+.project
+.pydevproject
+.settings
from vstorage import DocumentNotFound
from wiki import settings
-
class DocumentStorage(object):
def __init__(self, path):
self.vstorage = vstorage.VersionedStorage(path)
-
- def get(self, name, revision=None):
+
+ 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)
-
+ return Document(self, name = name, text = text)
+
def put(self, document, author, comment, parent):
self.vstorage.save_text(document.name, document.text, author, comment, parent)
class Document(object):
META_REGEX = re.compile(r'\s*<!--\s(.*?)-->', re.DOTALL | re.MULTILINE)
-
+
def __init__(self, storage, **kwargs):
self.storage = storage
for attr, value in kwargs.iteritems():
setattr(self, attr, value)
-
+
def revision(self):
try:
return self.storage._info(self.name)[0]
except DocumentNotFound:
- return -1
+ return - 1
def plain_text(self):
return re.sub(self.META_REGEX, '', self.text, 1)
-
+
def meta(self):
result = {}
-
+
m = re.match(self.META_REGEX, self.text)
if m:
for line in m.group(1).split('\n'):
result[k.strip()] = v.strip()
except ValueError:
continue
-
- return result
+ return result
+# Every time somebody says "let's have a global variable", God kills a kitten.
storage = DocumentStorage(settings.REPOSITORY_PATH)
-
+import unittest
+import wiki.models as models
+
+class TestDocument(unittest.TestCase):
+
+ def setUp(self):
+ models.storage = None
+
+ def
+
+
+
from wiki.models import storage, Document, DocumentNotFound
from wiki.forms import DocumentForm
-
-def document_list(request, template_name='wiki/document_list.html'):
- return direct_to_template(request, template_name, extra_context={
+def document_list(request, template_name = 'wiki/document_list.html'):
+ return direct_to_template(request, template_name, extra_context = {
'document_list': storage.all(),
})
-def document_detail(request, name, template_name='wiki/document_details.html'):
+def document_detail(request, name, template_name = 'wiki/document_details.html'):
try:
document = storage.get(name)
except DocumentNotFound:
- document = Document(storage, name=name, text='')
-
+ document = Document(storage, name = name, text = '')
+
if request.method == 'POST':
- form = DocumentForm(request.POST, instance=document)
+ form = DocumentForm(request.POST, instance = document)
if form.is_valid():
document = form.save()
return HttpResponse(json.dumps({'text': document.plain_text(), 'meta': document.meta(), 'revision': document.revision()}))
else:
return HttpResponse(json.dumps({'errors': form.errors}))
else:
- form = DocumentForm(instance=document)
-
- return direct_to_template(request, template_name, extra_context={
+ form = DocumentForm(instance = document)
+
+ return direct_to_template(request, template_name, extra_context = {
'document': document,
'form': form,
})
'django.contrib.admin',
'django.contrib.admindocs',
+ 'django_nose',
+
'wiki',
- 'piston',
'sorl.thumbnail',
'filebrowser',
'toolbar',
)
+TEST_RUNNER = 'django_nose.run_tests'
+
FILEBROWSER_URL_FILEBROWSER_MEDIA = STATIC_URL + 'filebrowser/'
FILEBROWSER_DIRECTORY = 'images/'
--find-links=http://stigma.nowoczesnapolska.org.pl/pypi/
Django==1.1.1
-lxml==2.2.2
+lxml>=2.2,<2.3
mercurial==1.3.1
librarian>=1.3.dev,<1.4
django-cas-consumer==0.1dev
PyYAML>=3.0
MySQL-python>=1.2,<2.0
+django-nose>=0.0.3