[Mpuls-commits] r1224 - in wasko/branches/2.0: . mpulsweb/lib waskaweb/lib waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 4 10:42:45 CET 2010
Author: torsten
Date: 2010-02-04 10:42:43 +0100 (Thu, 04 Feb 2010)
New Revision: 1224
Added:
wasko/branches/2.0/mpulsweb/lib/config.py
Removed:
wasko/branches/2.0/waskaweb/lib/config.py
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/lib/app_globals.py
wasko/branches/2.0/waskaweb/model/agencysettings.py
Log:
Moved lib/config into base
* waskaweb/lib/config.py,
mpulsweb/lib/config.py: Moved file
* waskaweb/model/agencysettings.py,
waskaweb/lib/app_globals.py: Import from new location
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-04 09:32:30 UTC (rev 1223)
+++ wasko/branches/2.0/ChangeLog 2010-02-04 09:42:43 UTC (rev 1224)
@@ -1,4 +1,13 @@
2010-02-04 Torsten Irländer <torsten.irlaender at intevation.de>
+
+ Moved lib/config into base
+
+ * waskaweb/lib/config.py,
+ mpulsweb/lib/config.py: Moved file
+ * waskaweb/model/agencysettings.py,
+ waskaweb/lib/app_globals.py: Import from new location
+
+2010-02-04 Torsten Irländer <torsten.irlaender at intevation.de>
Moved lib/timelog into base
* waskaweb/lib/timelog.py,
@@ -6,7 +15,6 @@
* waskaweb/lib/app_globals.py,
mpulsweb/lib/base.py: Import from base now.
-torsten at thoe:~/Projekte/mpuls/wasko/src/2.0
2010-02-04 Torsten Irländer <torsten.irlaender at intevation.de>
Moved model/annotations into base
Copied: wasko/branches/2.0/mpulsweb/lib/config.py (from rev 1211, wasko/branches/2.0/waskaweb/lib/config.py)
Property changes on: wasko/branches/2.0/mpulsweb/lib/config.py
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: wasko/branches/2.0/waskaweb/lib/app_globals.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/app_globals.py 2010-02-04 09:32:30 UTC (rev 1223)
+++ wasko/branches/2.0/waskaweb/lib/app_globals.py 2010-02-04 09:42:43 UTC (rev 1224)
@@ -32,10 +32,10 @@
from formed.meta.io.document import openDocument
from mpulsweb.lib.timelog import setupTimeLogging
+from mpulsweb.lib.config import MpulsConfig
from mpulsweb.model.annotations import AnnotationsProvider
import waskaweb.lib.security as security
-from waskaweb.lib.config import MpulsConfig
log = logging.getLogger(__name__)
Deleted: wasko/branches/2.0/waskaweb/lib/config.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/config.py 2010-02-04 09:32:30 UTC (rev 1223)
+++ wasko/branches/2.0/waskaweb/lib/config.py 2010-02-04 09:42:43 UTC (rev 1224)
@@ -1,185 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# (c) 2008 by Intevation GmbH
-# This is Free software under the GPLv3.
-# See LICENSE comming with the source of 'mpuls'
-# for details.
-#
-# author: Torsten Irländer <torsten.irlaender at intevation.de>
-#
-
-import os.path
-import logging
-
-import simplejson as json
-
-import pylons
-
-
-log = logging.getLogger(__name__)
-
-
-def get_revision():
- return "2.0-alpha"
-
-
-def get_path(dir, file):
- try:
- return os.path.join(pylons.config.get('pylons.paths')
- .get('static_files'), dir, file)
- except:
- return None # path building will fail on initial server start/restart
- # as pylonspath is empty
-
-def merge(a, b):
- '''recursive merge b into a. a is default, b is userdefined'''
- changes = []
- for ka, va in a.iteritems():
- try:
- vb = b[ka]
- except KeyError, err:
- continue
- if type(vb) == dict and type(va) == dict:
- merge(va, vb)
- elif vb != va:
- changes.append((ka, vb))
- a.update(changes)
-
-
-class MpulsConfig(object):
-
- def __init__(self, filename=None):
- self.config = self.build_defaults()
-
- if filename and os.path.isfile(filename):
- try:
- f = open(filename, "rb")
- try:
- log.info("Loading configfile: %s" % filename)
- cfg = json.load(f)
- log.info("Loading OK")
- finally:
- f.close()
- merge(self.config, cfg)
- except:
- log.exception("error processing config file %r.", filename)
-
- def build_defaults(self):
- '''Set default configuration. This is function should be calles if
- there is no config file'''
-
- sections = {}
-
- def set(section_key, item_key, item):
- try:
- section = sections[section_key]
- except KeyError:
- section = {}
- sections[section_key] = section
- section[item_key] = item
-
- set('common', 'name', 'mpuls')
- set('common', 'version', 'rev. %s' % get_revision())
- set('common', 'releasedate', '13.10.2010')
-
- # Formed
- set('formed', 'treefile', 'formedtree.xml')
- set('formed', 'annotation', 'annotations.xhtml')
-
- # Global Modules
- set('module', 'appointments', '1')
- set('module', 'documents', '1')
- set('module', 'evaluation', '1')
- set('module', 'news', '1')
-
- # Case Modules
- set('case-module', 'appointments', '1')
- set('case-module', 'import', '1')
- set('case-module', 'reminders', '1')
-
- # PHASES
- # --------
- # Available Phases:
- set('phases', 'phases', ["0","1","2"])
-
- # Description of phases
- description = [{
- "0": u"Eingangsdokumentation",
- "1": u"Case Management",
- "2": u"Nachbetreuung",
- }]
- set('phases', 'description', description)
-
- # Phasepairs
- pairs =[{
- "0": ["0","1"],
- "1": ["2","3"],
- "2": ["4","5"],
- }]
- set('phases', 'pairs', pairs)
- symbols = []
- set('phases', 'symbols', symbols)
-
- # Succenssors and Predesessors
- successors = [{
- "0": ["1"],
- "1": ["2"],
- "2": [],
- }]
- set('phases', 'successors', successors)
-
- # EVALUATIONS
- # ------------
- #
- dummy = {'name': 'Analyse', 'id': '4', 'config': 'eval_analyse.xml'}
- enabled_evaluations = [dummy]
- set('evaluations', 'enabled', enabled_evaluations)
- set('evaluations', 'default-start-date-field', 'erstgespraech')
- set('evaluations', 'default-end-date-field',
- 'coalesce(datum_cm_ende, now())')
-
- return sections
-
- def is_enabled(self, section, name):
- try:
- return self.get(section, name) == '1'
- except:
- log.error('Error on checking config (%s, %s)' % (section, name))
- return False
-
- def get(self, section, name):
- try:
- return self.config[section][name]
- except KeyError:
- log.error('Error on checking config (%s, %s)' % (section, name))
- return ''
-
- def get_app_name(self):
- return self.get('common', 'name')
-
- def get_app_version(self):
- return self.get('common', 'version')
-
- def get_releasedate(self):
- return self.get('common', 'releasedate')
-
- def get_overview_fields(self):
- return list(self.get('case-fields', 'overview'))
-
- def get_elementary_fields(self):
- return list(self.get('case-fields', 'elementary'))
-
- def get_individual_fields(self):
- return list(self.get('case-fields', 'individual'))
-
- def get_fieldname(self, key, mapping='case-fields-mapping'):
- '''Returns the mapped name of database field for a given mpuls internal
- datafield. If the field is not mapable return the key'''
- if not mapping:
- mapping = 'case-fields-mapping'
- try:
- return self.config[mapping][key]
- except KeyError:
- return key
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
Modified: wasko/branches/2.0/waskaweb/model/agencysettings.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/agencysettings.py 2010-02-04 09:32:30 UTC (rev 1223)
+++ wasko/branches/2.0/waskaweb/model/agencysettings.py 2010-02-04 09:42:43 UTC (rev 1224)
@@ -33,7 +33,7 @@
import psycopg2.extras
-from waskaweb.lib.config import get_path
+from mpulsweb.lib.config import get_path
from mpulsweb.lib.db import db
from waskaweb.lib.helpers import ensure_unicode
More information about the Mpuls-commits
mailing list