[Mpuls-commits] r700 - in wasko/branches/2.0/waskaweb: config lib templates/casemanagement
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Nov 23 14:49:51 CET 2009
Author: torsten
Date: 2009-11-23 14:49:50 +0100 (Mon, 23 Nov 2009)
New Revision: 700
Modified:
wasko/branches/2.0/waskaweb/config/environment.py
wasko/branches/2.0/waskaweb/lib/app_globals.py
wasko/branches/2.0/waskaweb/lib/config.py
wasko/branches/2.0/waskaweb/lib/validators.py
wasko/branches/2.0/waskaweb/templates/casemanagement/main.mako
wasko/branches/2.0/waskaweb/templates/casemanagement/new.mako
Log:
Load formedtree from formed dir under public. locltion of public can now be
configured.
Modified: wasko/branches/2.0/waskaweb/config/environment.py
===================================================================
--- wasko/branches/2.0/waskaweb/config/environment.py 2009-11-23 13:47:37 UTC (rev 699)
+++ wasko/branches/2.0/waskaweb/config/environment.py 2009-11-23 13:49:50 UTC (rev 700)
@@ -23,13 +23,17 @@
# European Social Fund resources.
"""Pylons environment configuration"""
import os
+import logging
+from mako.lookup import TemplateLookup
from pylons import config
import waskaweb.lib.app_globals as app_globals
import waskaweb.lib.helpers
from waskaweb.config.routing import make_map
+log = logging.getLogger(__name__)
+
def load_environment(global_conf, app_conf):
"""Configure the Pylons environment via the ``pylons.config``
object
@@ -42,6 +46,7 @@
templates=[os.path.join(root, 'templates')])
# Initialize config with the basic options
+ print "init: %s" % config
config.init_app(global_conf, app_conf, package='waskaweb',
template_engine='mako', paths=paths)
@@ -49,8 +54,37 @@
config['pylons.g'] = app_globals.Globals()
config['pylons.h'] = waskaweb.lib.helpers
+ template_urls = []
+ # Check for custom template location and add dir if locatio is defined.
+ custom_templates = config['pylons.g'].mpuls_config.get('paths', 'templates')
+ if custom_templates:
+ template_urls.append(custom_templates)
+ # Check for enabled addons and add template dirs if addon is enabled
+ #template_urls.extend(config['pylons.g'].mpuls_config.get_addons_templates())
+ #template_urls.append(os.path.join(root, 'templates'))
+ config['pylons.paths']['templates'] = template_urls
+ paths['templates'] = template_urls
+
+ # Create the Mako TemplateLookup, with the default auto-escaping
+ config['pylons.g'].mako_lookup = TemplateLookup(
+ directories=paths['templates'],
+ module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
+ input_encoding='utf-8', output_encoding='utf-8',
+ imports=['from webhelpers.html import escape'],
+ default_filters=['escape'])
+
# Customize templating options via this variable
tmpl_options = config['buffet.template_options']
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
+
+ # If the user configures a different location of images styles and such
+ # things, overwrite the default public location
+ public_path = config['pylons.g'].mpuls_config.get('paths', 'public')
+ if public_path:
+ print 'Starting with custom configuration for "public" directory: %s' % public_path
+ log.info('Starting with custom configuration for "public" directory: %s' % public_path)
+ config['pylons.paths']['static_files'] = public_path
+
+ print config['pylons.paths']['static_files']
Modified: wasko/branches/2.0/waskaweb/lib/app_globals.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/app_globals.py 2009-11-23 13:47:37 UTC (rev 699)
+++ wasko/branches/2.0/waskaweb/lib/app_globals.py 2009-11-23 13:49:50 UTC (rev 700)
@@ -32,7 +32,7 @@
import waskaweb.lib.security as security
from waskaweb.model.annotations import AnnotationsProvider
from waskaweb.lib.timelog import setupTimeLogging
-from waskaweb.lib.config import MpulsConfig
+from waskaweb.lib.config import MpulsConfig, get_path
from waskaweb.model.nodecomponents import RootNode
@@ -48,22 +48,6 @@
initialization and is available during requests via the 'g'
variable
"""
- # XXX: Dead ugly!
- path = os.path.join(os.path.dirname(__file__), '..', '..', 'formed')
- treeFile = os.path.join(path, 'formedtree_web.xml')
- annonFile = os.path.join(path, 'annotations.xhtml')
-
- # XXX: Check why the following throws key exceptions. Is config var not
- # availiable in Globals?!?
- #treeFile = os.path.join(os.path.dirname(__file__), config['formed_tree'])
- self.formedTree = openDocument(treeFile)
- try:
- self.helpData = AnnotationsProvider(annonFile)
- except:
- traceback.print_exc(file=sys.stderr)
- print >> sys.stderr, "Could not open Helpfile"
- self.helpData = None
-
# Load mpuls configuration
config_file = pylons.config['app_conf'].get('mpuls_config', 'mpuls.json')
if config_file:
@@ -76,6 +60,23 @@
self.config_path = os.path.dirname(config_file)
self.mpuls_config = MpulsConfig(config_file)
+ # Build FormedTree. This tree will work as template for als cases
+ custom_static = self.mpuls_config.get('paths', 'public')
+ default_static = pylons.config.get('pylons.paths').get('static_files')
+ formed_dir = 'formed'
+ if custom_static:
+ formed_dir = os.path.join(custom_static, formed_dir)
+ formed = get_path(formed_dir, self.mpuls_config.get('formed', 'treefile'))
+ annonFile = get_path(formed_dir, self.mpuls_config.get('formed', 'annotations'))
+
+ self.formedTree = openDocument(formed)
+ try:
+ self.helpData = AnnotationsProvider(annonFile)
+ except:
+ traceback.print_exc(file=sys.stderr)
+ print >> sys.stderr, "Could not open Helpfile"
+ self.helpData = None
+
# data for database connections
host = config.get('db_host')
Modified: wasko/branches/2.0/waskaweb/lib/config.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/config.py 2009-11-23 13:47:37 UTC (rev 699)
+++ wasko/branches/2.0/waskaweb/lib/config.py 2009-11-23 13:49:50 UTC (rev 700)
@@ -83,6 +83,10 @@
set('common', 'lang', 'en')
set('common', 'agencyname', 'Evaluationserver')
+ # Formed
+ set('formed', 'treefile', 'formedtree.xml')
+ set('formed', 'annotation', 'annotations.xhtml')
+
# Leave empty for default values
set('paths', 'public', '')
set('paths', 'i18n', '')
Modified: wasko/branches/2.0/waskaweb/lib/validators.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/validators.py 2009-11-23 13:47:37 UTC (rev 699)
+++ wasko/branches/2.0/waskaweb/lib/validators.py 2009-11-23 13:49:50 UTC (rev 700)
@@ -287,7 +287,7 @@
vorname = formencode.validators.String()
addresse_strasse = formencode.validators.String()
addresse_strassenr = formencode.validators.String()
- addresse_ort = formencode.validators.String()
+ addresse_ort = formencode.validators.String()
statement_signed = formencode.validators.Bool(if_missing=False)
aufnahme_typ = formencode.validators.Int(if_missing=0)
Modified: wasko/branches/2.0/waskaweb/templates/casemanagement/main.mako
===================================================================
--- wasko/branches/2.0/waskaweb/templates/casemanagement/main.mako 2009-11-23 13:47:37 UTC (rev 699)
+++ wasko/branches/2.0/waskaweb/templates/casemanagement/main.mako 2009-11-23 13:49:50 UTC (rev 700)
@@ -70,7 +70,7 @@
<ul>
<li><a href="/case/digest/${session.get('case').id}" onclick="return checkModification();"> ${_('cm_menu_link_digest')}</a></li>
% if h.hasRole(['cm_ka', 'admin_ka']):
- <li><a href="/case/phase/${session.get('case').id}" onclick="return checkModification();"> ${_('case_cm_phase')}</a></li>
+ <li><a href="/phase/overview/${session.get('case').id}" onclick="return checkModification();"> ${_('case_cm_phase')}</a></li>
<li><a href="/caselifetime/index/${session.get('case').id}" onclick="return checkModification();"> ${_('Verwaltung')}</a></li>
<li><a href="/case/organisation/${session.get('case').id}" onclick="return checkModification();"> ${_('cm_menu_link_organisation')}</a></li>
<li><a href="/case/appointments/${session.get('case').id}" onclick="return checkModification();"> ${_('cm_menu_link_appointment')}</a></li>
Modified: wasko/branches/2.0/waskaweb/templates/casemanagement/new.mako
===================================================================
--- wasko/branches/2.0/waskaweb/templates/casemanagement/new.mako 2009-11-23 13:47:37 UTC (rev 699)
+++ wasko/branches/2.0/waskaweb/templates/casemanagement/new.mako 2009-11-23 13:49:50 UTC (rev 700)
@@ -53,7 +53,7 @@
</tr>
<tr>
<td class="label">
- <label for="addresse_org">Ort:</label>
+ <label for="addresse_ort">Ort:</label>
</td>
<td>
<input class="field" type="text" size="50" maxlength="60" name="addresse_ort" id="addresse_ort" value="${c.case.city or ""}">
More information about the Mpuls-commits
mailing list