[qmtest] BUG: cancel during test creation causes error

Mark Mitchell mark at codesourcery.com
Mon Jan 12 22:27:30 UTC 2004


On Fri, 2004-01-09 at 14:02, Scott Lowrey wrote:
> I think this is a bug.  Pretty minor and probably too obscure to give
> much priority to.  
> 

But easily fixed with the following patch.

Applied.

-- 
Mark Mitchell <mark at codesourcery.com>
CodeSourcery, LLC
-------------- next part --------------
2004-01-12  Mark Mitchell  <mark at codesourcery.com>

	* qm/test/share/dtml/show.dtml: Add is_new field to form.
	* qm/test/web/web.py (QMTestServer.HandleShowItem): Pass a correct
	value for "new" to ShowItemPage.

Index: qm/test/share/dtml/show.dtml
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/share/dtml/show.dtml,v
retrieving revision 1.5
diff -c -5 -p -r1.5 show.dtml
*** qm/test/share/dtml/show.dtml	30 Jul 2003 21:25:31 -0000	1.5
--- qm/test/share/dtml/show.dtml	12 Jan 2004 22:23:52 -0000
***************
*** 66,75 ****
--- 66,78 ----
            name="class"
            value="<dtml-var expr="item.GetClassName()">" />
     <input type="hidden" 
            name="id"
            value="<dtml-var expr="item.GetId()">" />
+    <input type="hidden"
+           name="is_new"
+           value="<dtml-var new>" />
    </dtml-if>
  
    <table border="0"
           cellpadding="4"
           cellspacing="4"
Index: qm/test/web/web.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/web/web.py,v
retrieving revision 1.79
diff -c -5 -p -r1.79 web.py
*** qm/test/web/web.py	3 Jan 2004 04:02:59 -0000	1.79
--- qm/test/web/web.py	12 Jan 2004 22:23:52 -0000
*************** class QMTestServer(qm.web.WebServer):
*** 2041,2051 ****
                                     item_id=item_id,
                                     class_name=class_name,
                                     field_errors=field_errors)
                  return page(request)
  
!             # Construct an test with default argument values, as the
              # starting point for editing.
              if type is "resource":
                  item = self.MakeNewResource(class_name, item_id)
              elif type is "test":
                  item = self.MakeNewTest(class_name, item_id)
--- 2041,2051 ----
                                     item_id=item_id,
                                     class_name=class_name,
                                     field_errors=field_errors)
                  return page(request)
  
!             # Construct a test with default argument values, as the
              # starting point for editing.
              if type is "resource":
                  item = self.MakeNewResource(class_name, item_id)
              elif type is "test":
                  item = self.MakeNewTest(class_name, item_id)
*************** class QMTestServer(qm.web.WebServer):
*** 2255,2264 ****
--- 2255,2268 ----
          except KeyError:
              message = qm.error("no id for submit")
              return qm.web.generate_error_page(request, message)
  
          database = self.__database
+         # Learn whether or not this is a new item.
+         is_new = int(request["is_new"])
+         import sys
+         print >> sys.stderr, is_new
          # Extract the class and field specification.
          item_class_name = request["class"]
          item_class = qm.test.base.get_extension_class(item_class_name,
                                                        type,
                                                        self.GetDatabase())
*************** class QMTestServer(qm.web.WebServer):
*** 2305,2315 ****
  
          # If necessary, redisplay the form.
          if redisplay:
  	    request = qm.web.WebRequest("edit-" + type, base=request, 
                                          id=item_id)
! 	    return ShowItemPage(self, item, 1, 0, type, field_errors)(request)
  
          # Store it in the database.
          database.WriteExtension(item_id, item.GetItem())
  
          # Remove any attachments located in the temporary store as they
--- 2309,2320 ----
  
          # If necessary, redisplay the form.
          if redisplay:
  	    request = qm.web.WebRequest("edit-" + type, base=request, 
                                          id=item_id)
! 	    return ShowItemPage(self, item, 1, is_new, type,
!                                 field_errors)(request)
  
          # Store it in the database.
          database.WriteExtension(item_id, item.GetItem())
  
          # Remove any attachments located in the temporary store as they


More information about the qmtest mailing list