[Zope-CVS] CVS: Packages/JobBoardEx - JobEditView.pt:1.2 JobListView.pt:1.3 JobListView.py:1.12 JobPreviewView.pt:1.2 JobView.pt:1.4 JobView.py:1.6
Guido van Rossum
guido@python.org
Fri, 22 Mar 2002 21:12:05 -0500
Update of /cvs-repository/Packages/JobBoardEx
In directory cvs.zope.org:/tmp/cvs-serv628
Modified Files:
JobEditView.pt JobListView.pt JobListView.py JobPreviewView.pt
JobView.pt JobView.py
Log Message:
Put more magic in the joblist's custom traverser, to return a *view*
on the selected job rather than the selected job object. This makes
for nicer URLs. (I wish I could do the same for the joblist itself,
but somehow I can't figure out how to do that.)
=== Packages/JobBoardEx/JobEditView.pt 1.1 => 1.2 ===
<body>
<h1>Enter new job data</h1>
- <form action="." method="post">
+ <form action="" method="post">
<table border=0>
<tr><td>Submitter:</td>
<td><input name="submitter" type="text" value="" size="72"
=== Packages/JobBoardEx/JobListView.pt 1.2 => 1.3 ===
<h1>Job Board</h1>
-<A href="../new/edit;view/edit">Submit a new job</A>
+<A href="../new">Submit a new job</A>
<H2>Job Listings</H2>
@@ -13,7 +13,7 @@
<tr tal:repeat="job container/getApprovedJobs">
<td>
- <a href="jobid" tal:attributes="href string:../${job/id}/JobView;;view">
+ <a href="jobid" tal:attributes="href string:../${job/id}">
<span tal:replace="job/summary">A job summary</span></A>
</td>
</tr>
=== Packages/JobBoardEx/JobListView.py 1.11 => 1.12 ===
def browser_traverse(self, request, name):
+ job = None
if name == "new":
- return self.jobFromRequest(request)
- # First check if it's a request for a contained job
- try:
- jobid = int(name)
- except: # not sure what exceptions int() raises!!
- pass
+ # Special case: editing a new job
+ job = self.jobFromRequest(request)
+ view = "edit"
else:
- return self.joblist.lookup(jobid)
+ # Check if it's a request for a contained job
+ try:
+ jobid = int(name)
+ except: # not sure what exceptions int() raises!!
+ pass
+ else:
+ job = self.joblist.lookup(jobid)
+ view = "JobView"
+
+ if job is not None:
+ # Return a view on the job.
+ # XXX How to pass the joblist along?
+ view = getRequestView(job, view, request)
+ view.joblist = self.joblist
+ return view
# It wasn't a jobid. Return a view.
+ assert name != ""
return getRequestView(self.joblist, name, request)
def jobFromRequest(self, request):
=== Packages/JobBoardEx/JobPreviewView.pt 1.1 => 1.2 ===
<body>
- <form action="." method="post">
+ <form action="" method="post">
<table border=0>
<tr><td>Submitter:</td>
=== Packages/JobBoardEx/JobView.pt 1.3 => 1.4 ===
<body>
- <form action="../../" method="post">
+ <form action=".." method="post">
<table border=0>
<tr><td>Submitter:</td>
=== Packages/JobBoardEx/JobView.py 1.5 => 1.6 ===
from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
-from Zope.ComponentArchitecture import getRequestView
-from Zope.ContextWrapper import getcontext, getbaseobject
from IJob import IJob, JobState
@@ -41,11 +39,10 @@
preview = PageTemplateFile('JobPreviewView.pt')
def cancel(self, REQUEST):
- return REQUEST.response.redirect('../../')
+ return REQUEST.response.redirect('..')
def submit(self, REQUEST):
+ joblist = self.joblist
job = self.job
- joblist = getcontext(job)
- job = getbaseobject(job)
joblist.add(job)
- return REQUEST.response.redirect('../../')
+ return REQUEST.response.redirect('..')