Usunąłem "piston" z listy INSTALLED_APPS
# Netbeans garbage
nbproject
# Netbeans garbage
nbproject
-nbproject/*
\ No newline at end of file
+nbproject/*
+
+# Eclipse
+.project
+.pydevproject
+.settings
from vstorage import DocumentNotFound
from wiki import settings
from vstorage import DocumentNotFound
from wiki import settings
class DocumentStorage(object):
def __init__(self, path):
self.vstorage = vstorage.VersionedStorage(path)
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)
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)
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)
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 __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:
def revision(self):
try:
return self.storage._info(self.name)[0]
except DocumentNotFound:
def plain_text(self):
return re.sub(self.META_REGEX, '', self.text, 1)
def plain_text(self):
return re.sub(self.META_REGEX, '', self.text, 1)
def meta(self):
result = {}
def meta(self):
result = {}
m = re.match(self.META_REGEX, self.text)
if m:
for line in m.group(1).split('\n'):
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
result[k.strip()] = v.strip()
except ValueError:
continue
+# Every time somebody says "let's have a global variable", God kills a kitten.
storage = DocumentStorage(settings.REPOSITORY_PATH)
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
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(),
})
'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:
try:
document = storage.get(name)
except DocumentNotFound:
- document = Document(storage, name=name, text='')
-
+ document = Document(storage, name = name, text = '')
+
if request.method == 'POST':
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:
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,
})
'document': document,
'form': form,
})
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.admin',
'django.contrib.admindocs',
'sorl.thumbnail',
'filebrowser',
'toolbar',
)
'sorl.thumbnail',
'filebrowser',
'toolbar',
)
+TEST_RUNNER = 'django_nose.run_tests'
+
FILEBROWSER_URL_FILEBROWSER_MEDIA = STATIC_URL + 'filebrowser/'
FILEBROWSER_DIRECTORY = 'images/'
FILEBROWSER_URL_FILEBROWSER_MEDIA = STATIC_URL + 'filebrowser/'
FILEBROWSER_DIRECTORY = 'images/'
--find-links=http://stigma.nowoczesnapolska.org.pl/pypi/
Django==1.1.1
--find-links=http://stigma.nowoczesnapolska.org.pl/pypi/
Django==1.1.1
mercurial==1.3.1
librarian>=1.3.dev,<1.4
django-cas-consumer==0.1dev
PyYAML>=3.0
MySQL-python>=1.2,<2.0
mercurial==1.3.1
librarian>=1.3.dev,<1.4
django-cas-consumer==0.1dev
PyYAML>=3.0
MySQL-python>=1.2,<2.0