[Mpuls-commits] r1665 - in wasko/branches/2.0: . mpulsweb/model waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 18 19:11:09 CET 2010


Author: bh
Date: 2010-02-18 19:11:07 +0100 (Thu, 18 Feb 2010)
New Revision: 1665

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/model/case.py
   wasko/branches/2.0/waskaweb/model/case.py
Log:
* mpulsweb/model/case.py (Field): Added. Moved from waskaweb

* waskaweb/model/case.py (Field): Removed. Moved to mpulsweb


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-18 17:21:05 UTC (rev 1664)
+++ wasko/branches/2.0/ChangeLog	2010-02-18 18:11:07 UTC (rev 1665)
@@ -1,5 +1,11 @@
 2010-02-18  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/model/case.py (Field): Added. Moved from waskaweb
+
+	* waskaweb/model/case.py (Field): Removed. Moved to mpulsweb
+
+2010-02-18  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/lib/base.py: Import LoadCaseNotExistsError directly
 	from mpulsweb
 

Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-02-18 17:21:05 UTC (rev 1664)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-02-18 18:11:07 UTC (rev 1665)
@@ -32,6 +32,7 @@
 from formed.meta.data import RepeatNode
 
 from mpulsweb.lib.base import g
+from mpulsweb.lib.helpers import ensure_unicode
 
 
 log = logging.getLogger(__name__)
@@ -78,3 +79,88 @@
     else:
         rg = rgs[idx]
     return '%s:%s:%s' % (name, rg.getInternalIdentifier(), id)
+
+
+
+class Field(object):
+
+    """Class providing extra information about an attribute of the case.
+
+    The constructor parameters and public instance variables are:
+
+       name -- The name of the attribute.  This should be the name used
+               in the master table in the database which usually means
+               that it's the name in the formed meta tree (but not in a
+               repeat group).
+               The value of the field can be fetched with the case
+               object's get_value method
+
+       digest -- If true (default false), the field will be listed in
+               the default case digest.
+
+       search_retrieve -- If true (default false), the field will be
+               returned from a search.  This only works if the name is a
+               column of the master table.
+
+       search_match -- If true (default false), the search string
+               entered by the user will be matched against the value of
+               this field.  This will only work if the name is a column
+               of the master table.  search_match and search_retrieve
+               are completely independent settings.
+
+       preload -- If true (default false), the field will be loaded from
+               the database explicitly when creating a Case object from
+               an id using CaseFactory.loadById.  This flag must be set
+               for all fields from the master table that cannot be
+               loaded using the formed tree, because otherwise the
+               fields won't be available through the case object at all.
+               For other fields it can be an optimization to set this
+               flag.
+
+       alias -- Additional name under which the attribute can be
+               accessed directly as an attribute of the case object.
+               Default is None, which means that the field is not
+               available under an alias.
+
+       alias_force_string -- If true (default), the value will be forced
+               to be a unicode string using the ensure_unicode function
+               when it is accessed through the alias name.
+               This setting only has an affect if alias is not None.
+
+       session -- If true (default false) the field is available with
+               the alias name from the SessionCase object too.
+               This setting only has an affect if alias is not None.
+    """
+
+    def __init__(self, name, digest=False,
+                 search_retrieve=False, search_match=False,
+                 session=False, preload=False,
+                 alias=None, alias_force_string=True):
+        self.name = name
+        self.digest = digest
+        self.search_retrieve = search_retrieve
+        self.search_match = search_match
+
+        self.session = session
+        self.preload = preload
+        self.alias = alias
+        self.alias_force_string = alias_force_string
+
+    def get_default(self):
+        """Return the default value when accessed via the alias name"""
+        if self.alias_force_string:
+            return ""
+        else:
+            return None
+
+    default = property(get_default)
+
+    def convert(self, value):
+        """Convert the value when accessed via the alias name.
+        If alias_force_string is true, the value is forced to a unicode
+        string with the ensure_unicode method.  Otherwise it is returned
+        as-is.
+        """
+        if self.alias_force_string:
+            value = ensure_unicode(value)
+        return value

Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py	2010-02-18 17:21:05 UTC (rev 1664)
+++ wasko/branches/2.0/waskaweb/model/case.py	2010-02-18 18:11:07 UTC (rev 1665)
@@ -50,7 +50,8 @@
 from mpulsweb.model.user import UserObject
 from mpulsweb.model.agencysettings import Agency
 from mpulsweb.model.document import listDocuments
-from mpulsweb.model.case import LoadCaseNotExistsError, get_field_identifier
+from mpulsweb.model.case import Field, LoadCaseNotExistsError, \
+     get_field_identifier
 
 from mpulsweb.controllers.formularpage import convert2dic
 
@@ -578,92 +579,6 @@
         return True
 
 
-class Field(object):
-
-    """Class providing extra information about an attribute of the case.
-
-    The constructor parameters and public instance variables are:
-
-       name -- The name of the attribute.  This should be the name used
-               in the master table in the database which usually means
-               that it's the name in the formed meta tree (but not in a
-               repeat group).
-               The value of the field can be fetched with the case
-               object's get_value method
-
-       digest -- If true (default false), the field will be listed in
-               the default case digest.
-
-       search_retrieve -- If true (default false), the field will be
-               returned from a search.  This only works if the name is a
-               column of the master table.
-
-       search_match -- If true (default false), the search string
-               entered by the user will be matched against the value of
-               this field.  This will only work if the name is a column
-               of the master table.  search_match and search_retrieve
-               are completely independent settings.
-
-       preload -- If true (default false), the field will be loaded from
-               the database explicitly when creating a Case object from
-               an id using CaseFactory.loadById.  This flag must be set
-               for all fields from the master table that cannot be
-               loaded using the formed tree, because otherwise the
-               fields won't be available through the case object at all.
-               For other fields it can be an optimization to set this
-               flag.
-
-       alias -- Additional name under which the attribute can be
-               accessed directly as an attribute of the case object.
-               Default is None, which means that the field is not
-               available under an alias.
-
-       alias_force_string -- If true (default), the value will be forced
-               to be a unicode string using the ensure_unicode function
-               when it is accessed through the alias name.
-               This setting only has an affect if alias is not None.
-
-       session -- If true (default false) the field is available with
-               the alias name from the SessionCase object too.
-               This setting only has an affect if alias is not None.
-
-    """
-
-
-    def __init__(self, name, digest=False,
-                 search_retrieve=False, search_match=False,
-                 session=False, preload=False,
-                 alias=None, alias_force_string=True):
-        self.name = name
-        self.digest = digest
-        self.search_retrieve = search_retrieve
-        self.search_match = search_match
-
-        self.session = session
-        self.preload = preload
-        self.alias = alias
-        self.alias_force_string = alias_force_string
-
-    def get_default(self):
-        """Return the default value when accessed via the alias name"""
-        if self.alias_force_string:
-            return ""
-        else:
-            return None
-
-    default = property(get_default)
-
-    def convert(self, value):
-        """Convert the value when accessed via the alias name.
-        If alias_force_string is true, the value is forced to a unicode
-        string with the ensure_unicode method.  Otherwise it is returned
-        as-is.
-        """
-        if self.alias_force_string:
-            value = ensure_unicode(value)
-        return value
-
-
 class Case:
 
     def __init__(self, id=None, state=None, preset=None):



More information about the Mpuls-commits mailing list