Wok is only a framework and does not know which configuratin is required
for each plugin. Based on that, the plugin is responsible for its API
configuration.
Update Kimchi configuration accordingly.
This patch also prevents the follwing error on server start up:
CherryPy Checker:
'/home/alinefm/wok/plugins/kimchi/ui/libs' (root + dir) is not an existing
filesystem path.
section: [/libs]
root: None
dir: '/home/alinefm/wok/plugins/kimchi/ui/libs'
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
plugins/kimchi/config.py.in | 60 +++++++++++++++++++++++++--------------------
src/wok/config.py.in | 8 ++----
2 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/plugins/kimchi/config.py.in b/plugins/kimchi/config.py.in
index 4b82e45..6ae0ccd 100644
--- a/plugins/kimchi/config.py.in
+++ b/plugins/kimchi/config.py.in
@@ -23,7 +23,7 @@ import os
import platform
import threading
-from wok.config import PluginConfig, PluginPaths
+from wok.config import CACHEEXPIRES, PluginConfig, PluginPaths
from wok.xmlutils.utils import xpath_get_text
kimchiLock = threading.Lock()
@@ -107,32 +107,38 @@ class KimchiConfig(PluginConfig):
def __init__(self):
super(KimchiConfig, self).__init__('kimchi')
- custom_config = {
- '/novnc': {
+ static_config = {
+ '/novnc': {'type': 'dir',
+ 'path': kimchiPaths.novnc_dir},
+ '/spice-html5': {'type': 'dir',
+ 'path': kimchiPaths.spice_dir},
+ '/spice_auto.html': {'type': 'file',
+ 'path': kimchiPaths.spice_file},
+ '/spice-html5/spice.css': {'type': 'file',
+ 'path': kimchiPaths.spice_css_file}}
+
+ custom_config = {}
+ for uri, data in static_config.iteritems():
+ custom_config[uri] = {'tools.nocache.on': True,
+ 'tools.wokauth.on': True}
+ path = data['path']
+ if data['type'] == 'dir':
+ custom_config[uri].update({'tools.staticdir.on': True,
+ 'tools.staticdir.dir': path})
+ elif data['type'] == 'file':
+ custom_config[uri].update({'tools.staticfile.on': True,
+ 'tools.staticfile.filename': path})
+
+ for dirname in ('css', 'js', 'images'):
+ custom_config['/' + dirname] = {
'tools.staticdir.on': True,
- 'tools.staticdir.dir': kimchiPaths.novnc_dir,
- 'tools.nocache.on': True,
- 'tools.wokauth.on': True,
- },
-
- '/spice_auto.html': {
- 'tools.staticfile.on': True,
- 'tools.staticfile.filename': kimchiPaths.spice_file,
- 'tools.nocache.on': True,
- 'tools.wokauth.on': True,
- },
-
- '/spice-html5': {
- 'tools.staticdir.on': True,
- 'tools.staticdir.dir': kimchiPaths.spice_dir,
- 'tools.nocache.on': True,
- },
-
- '/spice-html5/spice.css': {
- 'tools.staticfile.on': True,
- 'tools.staticfile.filename': kimchiPaths.spice_css_file,
- 'tools.nocache.on': True,
- },
- }
+ 'tools.staticdir.dir': os.path.join(kimchiPaths.ui_dir,
+ dirname),
+ 'tools.wokauth.on': False,
+ 'tools.nocache.on': False}
+ if dirname != 'images':
+ custom_config['/' + dirname].update({
+ 'tools.expires.on': True,
+ 'tools.expires.secs': CACHEEXPIRES})
self.update(custom_config)
diff --git a/src/wok/config.py.in b/src/wok/config.py.in
index da17257..616c013 100644
--- a/src/wok/config.py.in
+++ b/src/wok/config.py.in
@@ -25,6 +25,7 @@ from ConfigParser import SafeConfigParser
__version__ = "@wokversion@"
__release__ = "@wokrelease@"
+CACHEEXPIRES = 31536000 # expires is one year.
DEFAULT_LOG_LEVEL = "debug"
FONT_FILES = {'fontawesome': ['fontawesome-webfont.ttf'],
@@ -126,10 +127,6 @@ class PluginPaths(Paths):
class UIConfig(dict):
-
- # expires is one year.
- CACHEEXPIRES = 31536000
-
def __init__(self, paths):
ui_configs = {}
for sub_dir in ('css', 'js', 'libs', 'images'):
@@ -141,7 +138,7 @@ class UIConfig(dict):
if sub_dir != 'images':
ui_configs['/' + sub_dir].update({
'tools.expires.on': True,
- 'tools.expires.secs': self.CACHEEXPIRES})
+ 'tools.expires.secs': CACHEEXPIRES})
for font, files in FONT_FILES.iteritems():
paths = FONTS_PATH[font]
@@ -207,7 +204,6 @@ class PluginConfig(dict):
'config/tab-ext.xml'),
'tools.nocache.on': True}}
self.update(plugin_config)
- self.update(UIConfig(PluginPaths(plugin_name)))
def _get_config():
--
2.1.0