[Mpuls-commits] r1168 - in wasko/branches/2.0: . waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 2 17:44:37 CET 2010
Author: bh
Date: 2010-02-02 17:44:35 +0100 (Tue, 02 Feb 2010)
New Revision: 1168
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/model/case.py (CaseFactory.loadFromQueryResult)
(CaseFactory.loadByName): Rename loadByName to loadFromQueryResult
and change its parameters. loadFromQueryResult takes a single
query result row as a parameter and extracts the fields it needs.
(CaseOverview.search): Call loadFromQueryResult instead of
loadByName.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-02 16:44:33 UTC (rev 1167)
+++ wasko/branches/2.0/ChangeLog 2010-02-02 16:44:35 UTC (rev 1168)
@@ -1,5 +1,14 @@
2010-02-02 Bernhard Herzog <bh at intevation.de>
+ * waskaweb/model/case.py (CaseFactory.loadFromQueryResult)
+ (CaseFactory.loadByName): Rename loadByName to loadFromQueryResult
+ and change its parameters. loadFromQueryResult takes a single
+ query result row as a parameter and extracts the fields it needs.
+ (CaseOverview.search): Call loadFromQueryResult instead of
+ loadByName.
+
+2010-02-02 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/model/case.py (Case.get_preset_fields): New. Class
method to return a list of the field names that can be preset.
(CaseFactory._build_preset): New method to build a preset mapping
Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py 2010-02-02 16:44:33 UTC (rev 1167)
+++ wasko/branches/2.0/waskaweb/model/case.py 2010-02-02 16:44:35 UTC (rev 1168)
@@ -352,14 +352,7 @@
result = search.perform(search_str)
factory = CaseFactory()
for row in result:
- case = factory.loadByName(row['id'],
- row['vorname'],
- row['name'],
- row['fn'],
- row['bearbeiter_id'],
- row['s_id'],
- row['status'],
- row['zugriff'])
+ case = factory.loadFromQueryResult(row)
self.ds_list.append(case)
return self.ds_list
@@ -402,20 +395,21 @@
return Case(id, state=State(id), preset=self._build_preset(result))
- def loadByName(self, id, first_name, last_name, knr, bearbeiter_id,
- s_id, s_state, s_access):
- """This method does not actually loads a case from the database. It
- just returns a case object initiated with the provided parameters"""
- case = Case()
- case.id = int(id)
- case.first_name = ensure_unicode(first_name)
- case.last_name = ensure_unicode(last_name)
- case.knr = ensure_unicode(knr)
- case.editor = bearbeiter_id
- case.state = State()
- case.state.setData(s_id, id, s_state, s_access)
- return case
+ def loadFromQueryResult(self, result):
+ """Create a Case object from a DB query result row.
+ The result should be a dict-like object mapping the names used
+ in the formed tree to the values. Which fields can be used is
+ determined by the list returned by the Case's get_preset_fields
+ method. In addition to those fields, the row must contain the
+ following fields that will be used to instantiate the State
+ object: s_id, status, zugriff
+ """
+ id = result["id"]
+ state = State()
+ state.setData(result["s_id"], id, result["status"], result["zugriff"])
+ return Case(id, state=state, preset=self._build_preset(result))
+
def createNew(self, init=True, uuid=None, data=None):
"""This method creates a new case in the database and takes care about
creating the right dependencies for repeat groups. If 'init' is true
More information about the Mpuls-commits
mailing list