[Mpuls-commits] r1179 - in wasko/branches/2.0: . waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 2 18:19:35 CET 2010
Author: bh
Date: 2010-02-02 18:19:29 +0100 (Tue, 02 Feb 2010)
New Revision: 1179
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/model/case.py (CaseDigest, CaseField, CaseStringField)
(CaseAgeField): Removed. No longer used.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-02 17:17:37 UTC (rev 1178)
+++ wasko/branches/2.0/ChangeLog 2010-02-02 17:19:29 UTC (rev 1179)
@@ -1,5 +1,10 @@
2010-02-02 Bernhard Herzog <bh at intevation.de>
+ * waskaweb/model/case.py (CaseDigest, CaseField, CaseStringField)
+ (CaseAgeField): Removed. No longer used.
+
+2010-02-02 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/model/case.py (Case.getDigest): Removed. No longer
used.
Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py 2010-02-02 17:17:37 UTC (rev 1178)
+++ wasko/branches/2.0/waskaweb/model/case.py 2010-02-02 17:19:29 UTC (rev 1179)
@@ -573,110 +573,6 @@
db.recycleConnection(con, cur)
-class CaseField(object):
-
- def __init__(self, name, dbname=None):
- self.name = name
- if dbname is None:
- dbname = name
- self.dbname = dbname
-
- @classmethod
- def from_db(cls, obj):
- return obj
-
-
-class CaseStringField(CaseField):
-
- @classmethod
- def from_db(cls, obj):
- if obj is None:
- return u""
- return ensure_unicode(obj)
-
-
-class CaseAgeField(CaseField):
-
- @classmethod
- def from_db(cls, obj):
- if obj is None:
- obj = date.today()
- return (date.today() - obj).days / 365 or ""
-
-
-class CaseDigest:
-
- _fields = [
- CaseStringField("last_name", "name"),
- CaseStringField("first_name", "vorname"),
- CaseStringField("knr", "fn"),
- CaseAgeField("age", "geburtsdatum"),
- CaseStringField("street", "addresse_strasse"),
- CaseStringField("streetnr", "addresse_strassenr"),
- CaseStringField("plz", "addresse_plz"),
- CaseStringField("city", "addresse_ort"),
- ]
-
- _names = {}
- for _field in _fields:
- _names[_field.name] = _field
-
- def __init__(self, id):
- self.id = id
- self._loadFromDB(id)
-
- def _loadFromDB(self, id):
- result = {}
- try:
- factory = InstanceFactory(g.formedTree, PostgresDBInterface())
- self._it = factory.loadInstanceTreeByIdentifier(id)
- except:
- traceback.print_exc(file=sys.stderr)
-
- def __getattr__(self, name):
- log.debug("CaseDigest.__getattr__: name = %r", name)
- field = self._names.get(name)
- if field is not None:
- value = None
- fid = get_field_identifier(self.id, field.dbname, self._it)
- log.debug("CaseDigest.__getattr__: fid = %r", fid)
- if fid:
- item = self._it.getItem(fid)
- if item:
- value = item.getValue()
- self.__dict__[name] = field.from_db(value)
- return self.__dict__[name]
- else:
- raise AttributeError(name)
-
- def getValue(self, name):
- log.debug("CaseDigest.getValue: name = %r", name)
- fid = get_field_identifier(self.id, name, self._it)
- log.debug("CaseDigest.getValue: fid = %r", fid)
- if fid:
- item = self._it.getItem(fid)
- if item:
- value = item.getValue()
- if isinstance(value, str):
- value = ensure_unicode(value)
- self.__dict__[name] = value
- return value
- else:
- raise AttributeError(name)
-
- def getDescription(self, name):
- log.debug("CaseDigest.getDescription: name = %r", name)
- fid = get_field_identifier(self.id, name, self._it)
- log.debug("CaseDigest.getDescription: fid = %r", fid)
- if fid:
- item = self._it.getItem(fid)
- if item:
- return item.getMeta().getDescription()
- return "no description found"
- else:
- raise AttributeError(name)
-
-
class SessionCase:
"""This class holds all needed information for the currently selected case
More information about the Mpuls-commits
mailing list