[Mpuls-commits] r1649 - in wasko/branches/2.0: . waskaweb/lib waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 17 16:10:43 CET 2010


Author: bh
Date: 2010-02-17 16:10:42 +0100 (Wed, 17 Feb 2010)
New Revision: 1649

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/lib/app_globals.py
   wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/model/case.py (Case.fields, Case.alias_dict):
Removed. Will now be set in set_fields
(Case.set_fields): New.  Classmethod to set fields and create the
alias_dict.

* waskaweb/lib/app_globals.py (Globals._init_case): Set the Case
fields from the mpuls configuration


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-17 15:09:53 UTC (rev 1648)
+++ wasko/branches/2.0/ChangeLog	2010-02-17 15:10:42 UTC (rev 1649)
@@ -1,5 +1,15 @@
 2010-02-17  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/model/case.py (Case.fields, Case.alias_dict):
+	Removed. Will now be set in set_fields
+	(Case.set_fields): New.  Classmethod to set fields and create the
+	alias_dict.
+
+	* waskaweb/lib/app_globals.py (Globals._init_case): Set the Case
+	fields from the mpuls configuration
+
+2010-02-17  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/config.py (MpulsConfig.build_defaults): Add a
 	default field configuration
 

Modified: wasko/branches/2.0/waskaweb/lib/app_globals.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/app_globals.py	2010-02-17 15:09:53 UTC (rev 1648)
+++ wasko/branches/2.0/waskaweb/lib/app_globals.py	2010-02-17 15:10:42 UTC (rev 1649)
@@ -17,4 +17,6 @@
         self._init_case()
 
     def _init_case(self):
+        fields = self.mpuls_config.get("case", "fields")
+        Case.set_fields(fields)
         self.case_factory = CaseFactory(Case)

Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py	2010-02-17 15:09:53 UTC (rev 1648)
+++ wasko/branches/2.0/waskaweb/model/case.py	2010-02-17 15:10:42 UTC (rev 1649)
@@ -709,53 +709,6 @@
 
 class Case:
 
-    # Definitions for some commonly used public instance attributes.
-    #
-    fields = [
-        Field("name", digest=True, search_retrieve=True, search_match=True,
-              alias="last_name", alias_force_string=True, session=True,
-              preload=True),
-        Field("vorname", digest=True, search_retrieve=True, search_match=True,
-              alias="first_name", alias_force_string=True, session=True,
-              preload=True),
-        Field("fn", digest=True, search_retrieve=True, search_match=True,
-              alias="knr", alias_force_string=True, session=True,
-              preload=True),
-        Field("geburtsdatum", digest=True),
-        Field("addresse_strasse", digest=True,
-              alias="street", alias_force_string=True, session=True),
-        Field("addresse_strassenr", digest=True,
-              alias="streetnr", alias_force_string=True, session=True),
-        Field("addresse_plz", digest=True,
-              alias="plz", alias_force_string=True, session=True),
-        Field("addresse_ort", digest=True,
-              alias="city", alias_force_string=True, session=True),
-
-        Field("addresse_vorwahl", digest=True),
-        Field("addresse_telefonnummer", digest=True),
-        Field("addresse_weiteretelefonnummern", digest=True),
-        Field("addresse_email", digest=True),
-        Field("mutter_vn", digest=True),
-        Field("mutter_n", digest=True),
-        Field("mutter_vorwahl", digest=True),
-        Field("mutter_telefonnummer", digest=True),
-        Field("mutter_email", digest=True),
-        Field("vater_vn", digest=True),
-        Field("vater_n", digest=True),
-        Field("vater_vorwahl", digest=True),
-        Field("vater_telefonnummer", digest=True),
-        Field("vater_email", digest=True),
-
-        Field("erstgespraech", alias="first_meeting", session=True,
-              preload=True),
-        Field("datum_cm_ende", alias="cm_end", session=True, preload=True),
-        Field("bearbeiter_id", search_retrieve=True,
-              alias="editor", session=False, preload=True),
-        ]
-
-    alias_dict = dict((field.alias, field) for field in fields
-                                           if field.alias is not None)
-
     def __init__(self, id=None, state=None, preset=None):
         self.id = id
         self.state = state
@@ -770,6 +723,18 @@
         self.preset = preset
         self.formed_instance = None
 
+
+    @classmethod
+    def set_fields(cls, raw_fields):
+        # print "Case.set_fields",
+        # for kw in raw_fields:
+        #     print kw
+        fields = [Field(**kw) for kw in raw_fields]
+        cls.fields = fields
+        cls.alias_dict = dict((field.alias, field) for field in fields
+                                                   if field.alias is not None)
+
+
     def __getattr__(self, name):
         """Provide attribute like access to some fields for compatibility"""
         field = self.alias_dict.get(name)



More information about the Mpuls-commits mailing list