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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 4 12:19:53 CET 2010


Author: bh
Date: 2010-02-04 12:19:51 +0100 (Thu, 04 Feb 2010)
New Revision: 1238

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/model/case.py (CaseFactory.createNew): Use libformed's
createNewInstanceTree to create the new case instead of accessing
the database directly.
(CaseFactory._updateMasterOnCreate): Takes the instance tree and
not the case id as parameter now.  It doesn't access
session['uncommited_fields'] anymore as that doesn't make sense
for a completely new case.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-04 11:11:32 UTC (rev 1237)
+++ wasko/branches/2.0/ChangeLog	2010-02-04 11:19:51 UTC (rev 1238)
@@ -1,3 +1,13 @@
+2010-02-04  Bernhard Herzog  <bh at intevation.de>
+
+	* waskaweb/model/case.py (CaseFactory.createNew): Use libformed's
+	createNewInstanceTree to create the new case instead of accessing
+	the database directly.
+	(CaseFactory._updateMasterOnCreate): Takes the instance tree and
+	not the case id as parameter now.  It doesn't access
+	session['uncommited_fields'] anymore as that doesn't make sense
+	for a completely new case.
+
 2010-02-04  Torsten Irländer <torsten.irlaender at intevation.de>
 	
 

Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py	2010-02-04 11:11:32 UTC (rev 1237)
+++ wasko/branches/2.0/waskaweb/model/case.py	2010-02-04 11:19:51 UTC (rev 1238)
@@ -410,45 +410,26 @@
         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
-        will get initiated. This method returns the case object"""
-        conn, cur = None, None
-        try:
-            try:
-                conn = db.getConnection()
-                cur = conn.cursor()
-                cur.execute(CREATE_CASE_SQL, {'uuid': uuid})
-                id = int(cur.fetchone()[0])
-                conn.commit()
-            finally:
-                db.recycleConnection(conn, cur)
-        except:
-            print "Fehler"
-            traceback.print_exc(file=sys.stderr)
-            return None
+        """Create a new case in the database and return the case object.
+        The new case will use the given uuid and contain the data given
+        in the data parameter.  If the init parameter is true the case
+        will get initialized with some standard information like the
+        editor information.
+        """
+        factory = InstanceFactory(g.formedTree, PostgresDBInterface())
+        instance_tree = factory.createNewInstanceTree(uuid)
+        id = instance_tree.getRootNode().getIdentifier()
 
         if data:
-            self._updateMasterOnCreate(id, data)
+            self._updateMasterOnCreate(instance_tree, data)
 
         if init == True:
-            try:
-                self._initNewCase(id)
-                print "5"
-            except StandardError, err:
-                print "Error on initialising the case: %s" % err
-                raise
+            self._initNewCase(id)
 
-        case = Case()
-        case.id = id
-        print "6"
-        return case
+        return Case(id)
 
-    def _updateMasterOnCreate(self, id, data):
-        factory = InstanceFactory(g.formedTree, PostgresDBInterface())
-        instance_tree = factory.loadInstanceTreeByIdentifier(
-            id,
-            session.get('uncommited_fields'))
+    def _updateMasterOnCreate(self, instance_tree, data):
+        id = instance_tree.getRootNode().getIdentifier()
         try:
             form_result = convert2dic(data)
 



More information about the Mpuls-commits mailing list