[Zope-CVS] CVS: Packages/JobBoardEx - thanks.pt:1.1 ApproveJobsView.py:1.7 JobCreateView.py:1.6 Tutorial.html:1.18
Guido van Rossum
Mon, 17 Jun 2002 17:19:04 -0400
Update of /cvs-repository/Packages/JobBoardEx
In directory cvs.zope.org:/tmp/cvs-serv6979
ApproveJobsView.py JobCreateView.py Tutorial.html
More variation in redirection, to server as a a more varied example.
=== Added File Packages/JobBoardEx/thanks.pt ===
<title>Thank you for your job submission</title>
<h1>Thank you for your job submission</h1>
<p>Our site manager will review and publish it shortly. Please use
one of the following links to continue to use our site:
<li><a href="/">Back to site home</a>
<p><li><a href=".">Back to job board</a>
<p><li><a href="edit.html">Submit another job</a>
=== Packages/JobBoardEx/ApproveJobsView.py 1.6 => 1.7 ===
+ response = self.request.getResponse()
+ if self.context.getPendingIds():
=== Packages/JobBoardEx/JobCreateView.py 1.5 => 1.6 ===
preview = ViewPageTemplateFile('preview.pt')
+ thanks = ViewPageTemplateFile('thanks.pt')
def create(self, submitter='', summary='', description='', contact=''):
# Validation code should go here
job = Job(submitter, summary, description, contact)
+ return self.thanks()
=== Packages/JobBoardEx/Tutorial.html 1.17 => 1.18 ===
<p>Finally, the create() method must send a response to the browser.
-There are different ways to do that. The example uses a simple
-redirection that sends the browser back to the job list.
+There are different ways to do that. The example invokes another page
+template, <a href="thanks.pt">thanks.pt</a>, which displays a
+thank-you message and offers several links to continue browsing.
<p>A more realistic create() method should include validation code,
e.g. checking that all fields are filled in, and perhaps attempting
@@ -437,10 +438,14 @@
the job, and it remains in the PendingApproval state.
<p>Finally, the approve() method directs the browser back to the view
-named review.html. As an aside, note that this means we can't just
-change the name of that form in the configuration directives and the
-page templates; we'd have to change it in the Python code for the
-approve() method too.
+named review.html. In contrast with the JobCreateView class, which
+invoked a page template at this point, we "redirect" the browser to
+another page. This is done by calling the redirect() method of the
+response object with the (relative) URL of the new page. The response
+is retrieved from the request by calling its getResponse() method. As
+an example of the power of this approach, we redirect to the review
+page if there are more jobs to review, but to the default view of the
+job list if there are no more jobs to review.