[Zope-CVS] CVS: Packages/JobBoardEx - ApproveJobsView.py:1.2 IJobList.py:1.6 JobList.py:1.12 JobList.zcml:1.20 JobListTraverser.py:NONE

Jim Fulton jim@zope.com
Tue, 11 Jun 2002 19:14:51 -0400


Update of /cvs-repository/Packages/JobBoardEx
In directory cvs.zope.org:/tmp/cvs-serv10222

Modified Files:
	ApproveJobsView.py IJobList.py JobList.py JobList.zcml 
Removed Files:
	JobListTraverser.py 
Log Message:
Refactored JobList to use __getitem__ rather than lookup.

This allowed is to assert that JobList implemented IItemContainer,
which got us a traverser. We made this assertion in the zcml file so
as not to much up the IJobList interface.

Also added a defaultView directive to mark index.html as JobLists
default view.


=== Packages/JobBoardEx/ApproveJobsView.py 1.1 => 1.2 ===
         for variable in form:
             try:
-                id = int(variable)
+                job = self.context.lookup(id)
+            except KeyError:
+                raise
             except:
                 continue
 
-            job = self.context.lookup(id)
             action = form[variable]
             if action == 'approve':
                 job.approve()


=== Packages/JobBoardEx/IJobList.py 1.5 => 1.6 ===
 class IJobList(Interface):
 
+    def __getitem__(id):
+        """Returns the job with the given id"""
+
     def query(state):
         """Returns a list of Job objects"""
 
@@ -11,12 +14,6 @@
 
     def getPendingJobs():
         """Returns a sequence of the jobs that are in the pending state
-        """
-
-    def lookup(jobid):
-        """Returns the job corresponding to jobid.
-
-        Raises KeyError if jobid is not in list.
         """
 
     def add(job):


=== Packages/JobBoardEx/JobList.py 1.11 => 1.12 ===
                 if job.state == state]
 
-    def lookup(self, jobid):
+    def __getitem__(self, jobid):
+        jobid = int(jobid)
+        
         for job in self.jobs:
             if job.id == jobid:
                 return job


=== Packages/JobBoardEx/JobList.zcml 1.19 => 1.20 ===
                 />
    <security:allow interface=".IJobList." />
+   <implements interface="Zope.App.OFS.Container.IContainer.IItemContainer" />
 </content>
 
 <content class=".Job.">
@@ -22,10 +23,9 @@
               permission="Zope.Public" 
               />
 
-<browser:view name="_traverse"
-              for=".IJobList."
-              factory=".JobListTraverser." 
-              />
+<browser:defaultView for=".IJobList."
+                     name="index.html"
+                     />
 
 <browser:view for=".IJobList."
               factory=".JobCreateView."

=== Removed File Packages/JobBoardEx/JobListTraverser.py ===