[Zope-CVS] CVS: Packages/JobBoardEx/Views/Browser - NewJob.py:1.6

Barry Warsaw barry@wooz.org
Wed, 20 Mar 2002 15:34:06 -0500


Update of /cvs-repository/Packages/JobBoardEx/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv5084

Modified Files:
	NewJob.py 
Log Message:
setViewRequest(): If we're viewing the NewJob page, this method will
still get called, but there won't be any form variables, so just
ignore the KeyErrors.  Set self.job to None (it should be ignored).

cancel(): Fix the redirect as per the XXX comment.



=== Packages/JobBoardEx/Views/Browser/NewJob.py 1.5 => 1.6 ===
     waiting = PageTemplateFile('Waiting.pt')
 
-    def setViewRequest(self, request):
-        self.request = request
-        self.job = Job(request['submitter'],
-                       request['summary'],
-                       request['description'],
-                       request['contact'])
+    def setViewRequest(self, REQUEST):
+        self.request = REQUEST
+        # If we're viewing the NewJob page, this method will still get called,
+        # but there won't be any form variables, so just ignore the KeyErrors
+        try:
+            self.job = Job(REQUEST['submitter'],
+                           REQUEST['summary'],
+                           REQUEST['description'],
+                           REQUEST['contact'])
+        except KeyError:
+            self.job = None
 
     def getJobView(self):
         view = getRequestView(self.job, 'JobView', self.request)
         return view.simpleView(self.request)
 
     def cancel(self, REQUEST):
-        # XXX This redirect will change
-        return REQUEST.RESPONSE.redirect('Hello.pt')
+        return REQUEST.response.redirect('..')
 
     home = cancel
 
     def submit(self, submitter, summary, description, contact, REQUEST):
         """Edits a job object."""
         joblist = self.getContext()
-        job = Job(submitter, summary, description, '', contact)
+        job = Job(submitter, summary, description, contact)
         joblist.add(job)
         return self.waiting(REQUEST)