[Mpuls-commits] r2114 - wasko/branches/2.0/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 24 15:42:30 CET 2010


Author: torsten
Date: 2010-03-24 15:42:29 +0100 (Wed, 24 Mar 2010)
New Revision: 2114

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (SessionCase): New. Copied from jmdweb.


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-03-24 14:39:46 UTC (rev 2113)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-03-24 14:42:29 UTC (rev 2114)
@@ -702,6 +702,47 @@
             db.recycleConnection(conn, cur)
         return False
 
+class SessionCase:
+
+    """This class holds all needed information for the currently selected case
+    """
+
+    def __init__(self, id=None, page_id=None, state=None,
+                 privacy_statement=False, **kw):
+        if id is None:
+            self.id = None
+        else:
+            self.id = int(id)
+
+        self.page_id = page_id
+        self.state = state
+        self.privacy_statement = privacy_statement
+
+        for field in self._session_fields():
+            setattr(self, field.alias, kw.get(field.alias, field.default))
+
+    def _session_fields(self):
+        return g.case_factory.get_session_fields()
+
+    def getState(self):
+        return self.state
+
+    def setPageId(self, id):
+        self.page_id = id
+
+    def getPageId(self):
+        return self.page_id
+
+    def hasPrivacyStatement(self):
+        return self.privacy_statement
+
+    def setData(self, params):
+        for field in self._session_fields():
+            setattr(self, field.alias,
+                    field.convert(save_getone(params, field.name,
+                                              field.default)))
+
+
 class MpulsCaseFactory:
 
     """Factory for case object. This factory provides methods to either load



More information about the Mpuls-commits mailing list