provide simple editing view for wiki configuration settings
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@4023 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
b807819ea1
commit
56f75689aa
2 changed files with 39 additions and 0 deletions
|
@ -3,6 +3,13 @@
|
||||||
|
|
||||||
<metal:content define-macro="manager">
|
<metal:content define-macro="manager">
|
||||||
<h1>Wiki Manager</h1>
|
<h1>Wiki Manager</h1>
|
||||||
|
<h2>Settings</h2>
|
||||||
|
<form method="post">
|
||||||
|
<input type="hidden" name="form.action" value="apply" />
|
||||||
|
<textarea rows="10" cols="50" name="config"
|
||||||
|
tal:content="view/configForEditing" /><br />
|
||||||
|
<input type="submit" name="apply" value="Apply" />
|
||||||
|
</form>
|
||||||
<h2>Wikis</h2>
|
<h2>Wikis</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr tal:repeat="wiki view/listWikis">
|
<tr tal:repeat="wiki view/listWikis">
|
||||||
|
|
|
@ -42,6 +42,16 @@ class WikiBaseView(object):
|
||||||
portlet_left=[self.default_template.macros['navigation']],
|
portlet_left=[self.default_template.macros['navigation']],
|
||||||
portlet_right=[])
|
portlet_right=[])
|
||||||
|
|
||||||
|
def configForEditing(self):
|
||||||
|
lines = []
|
||||||
|
for k, v in self.context.getConfigInfo().items():
|
||||||
|
if isinstance(v, (list, tuple)):
|
||||||
|
v = '[%s]' % ', '.join(v)
|
||||||
|
if v is None:
|
||||||
|
v = ''
|
||||||
|
lines.append('%s: %s' % (k, v))
|
||||||
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
class WikiManagerView(WikiBaseView):
|
class WikiManagerView(WikiBaseView):
|
||||||
|
|
||||||
|
@ -49,8 +59,30 @@ class WikiManagerView(WikiBaseView):
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
form = self.request.form
|
form = self.request.form
|
||||||
|
if form.get('form.action') == 'apply' and 'config' in form:
|
||||||
|
self.processConfigData(form['config'])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def processConfigData(self, input):
|
||||||
|
for line in input.splitlines():
|
||||||
|
if line:
|
||||||
|
self.processConfigLine(line)
|
||||||
|
|
||||||
|
def processConfigLine(self, line):
|
||||||
|
value = None
|
||||||
|
k, v = line.split(':', 1)
|
||||||
|
key = k.strip()
|
||||||
|
v = v.strip()
|
||||||
|
if v:
|
||||||
|
if v.startswith('[') and v.endswith(']'):
|
||||||
|
value = [s.strip() for s in v[1:-1].split(',')]
|
||||||
|
else:
|
||||||
|
value = v
|
||||||
|
if not value:
|
||||||
|
value = None
|
||||||
|
if value != self.context.getConfig(key):
|
||||||
|
self.context.setConfig(key, value)
|
||||||
|
|
||||||
def listWikis(self):
|
def listWikis(self):
|
||||||
return self.context.listWikis()
|
return self.context.listWikis()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue