[Mpuls-commits] r4520 - base/trunk/mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jan 24 23:13:02 CET 2011


Author: torsten
Date: 2011-01-24 23:13:01 +0100 (Mon, 24 Jan 2011)
New Revision: 4520

Modified:
   base/trunk/mpulsweb/lib/app_globals.py
Log:
* mpulsweb/lib/app_globals.py (Globals._init_case): Try to load case
  and casefactory from overrideable modul. If this fails load case
  and case factory from base.


Modified: base/trunk/mpulsweb/lib/app_globals.py
===================================================================
--- base/trunk/mpulsweb/lib/app_globals.py	2011-01-24 22:07:35 UTC (rev 4519)
+++ base/trunk/mpulsweb/lib/app_globals.py	2011-01-24 22:13:01 UTC (rev 4520)
@@ -42,6 +42,7 @@
 from mpulsweb.model.annotations import AnnotationsProvider
 
 
+
 log = logging.getLogger(__name__)
 
 
@@ -126,15 +127,24 @@
 
     def _init_case(self):
         from mpulsweb.model.agency import MpulsAgencyFactory, MpulsAgency
+        from mpulsweb.model.case import MpulsCase, MpulsCaseFactory
         """Set the mpuls application specific case classes"""
-        case_module = import_overridable_module("model.case")
-        self.case = case_module.Case
+        try:
+            case_module = import_overridable_module("model.case")
+            Case = case_module.Case
+            self.case = Case
+            CaseFactory = case_module.CaseFactory
+            self.case_factory = case_module.CaseFactory(self.case)
+        except:
+            log.warning('Not found "model.case in overridable module. Taking case from base"')
+            self.case = MpulsCase
+            self.case_factory = MpulsCaseFactory(self.case)
+
         self.agency = MpulsAgency 
 
         self.case.set_fields(self.mpuls_config.get("case", "fields"))
         self.agency.set_fields(self.mpuls_config.get("agency", "fields"))
 
-        self.case_factory = case_module.CaseFactory(self.case)
         self.agency_factory = MpulsAgencyFactory(self.agency)
 
         search_module = import_overridable_module("lib.search")



More information about the Mpuls-commits mailing list