[Zope-CVS] CVS: Packages/JobBoardEx - ApproveJobs.py:1.3 Job.py:1.7 JobList.py:1.9 JobListView.py:1.10 JobView.py:1.4 NewJob.py:1.4

Guido van Rossum guido@python.org
Thu, 21 Mar 2002 13:03:45 -0500


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

Modified Files:
	ApproveJobs.py Job.py JobList.py JobListView.py JobView.py 
	NewJob.py 
Log Message:
Get rid of ContextDependent; get rid of long imports from this package.

=== Packages/JobBoardEx/ApproveJobs.py 1.2 => 1.3 ===
 from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
-from Zope.ComponentArchitecture.ContextDependent import ContextDependent
 
-from ZopeProducts.JobBoardEx.IJob import JobState
+from IJobList import IJobList
+from IJob import JobState
+
+class ApproveJobs(AttributePublisher):
+
+    __used_for__ = IJobList
+
+    def __init__(self, joblist):
+        self.joblist = joblist
+
+    def getContext(self):
+        return self.joblist
 
-class ApproveJobs(AttributePublisher, ContextDependent):
     index = PageTemplateFile('ApproveJobs.pt')
 
     def cancel(self, REQUEST):
@@ -14,8 +23,7 @@
 
     def submit(self, REQUEST):
         """Approve a job."""
-        joblist = self.getContext()
-        for job in joblist.query(JobState.PendingApproval):
+        for job in self.joblist.query(JobState.PendingApproval):
             jobid = 'job_%s' % job.id
             value = REQUEST.get(jobid, None)
             if value == 'defer':
@@ -24,7 +32,7 @@
                 job.approve()
             elif value == 'discard':
                 # XXX This might change
-                joblist.remove(job)
+                self.joblist.remove(job)
             else:
                 # Malicious form poster!
                 pass


=== Packages/JobBoardEx/Job.py 1.6 => 1.7 ===
 
 class Job(Persistent):
-    __implements__ = IJob,
+
+    __implements__ = IJob
 
     def __init__(self, submitter, summary, description, contact):
         self.submitter = submitter


=== Packages/JobBoardEx/JobList.py 1.8 => 1.9 ===
      import getRequestView, getRequestDefaultViewName
 
-from ZopeProducts.JobBoardEx.IJobList import IJobList
+from IJobList import IJobList
 
 class JobList(Persistent):
 
@@ -12,6 +12,9 @@
     def __init__(self):
         self.id = 0
         self.jobs = PersistentList()
+
+    def getContext(self):
+        return self.joblist
 
     def add(self, job):
         # XXX do we have to worry about thread safety?


=== Packages/JobBoardEx/JobListView.py 1.9 => 1.10 ===
 from Zope.PageTemplate import PageTemplateFile
 
-from ZopeProducts.JobBoardEx.IJobList import IJobList
-from ZopeProducts.JobBoardEx.IJob import JobState
+from IJobList import IJobList
+from IJob import JobState
 
 class JobListSummaryView(AttributePublisher):
 
+    __used_for__ = IJobList
+
     def __init__(self, joblist):
         self.joblist = joblist
 
     def getContext(self):
         return self.joblist
-
-    __used_for__ = IJobList
 
     def getApprovedJobs(self):
         return self.joblist.query(JobState.Approved)


=== Packages/JobBoardEx/JobView.py 1.3 => 1.4 ===
 from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
 
+from IJob import IJob, JobState
+
 
 class JobView(AttributePublisher):
+
+    __used_for__ = IJob
 
     def __init__(self, job):
         self.job = job


=== Packages/JobBoardEx/NewJob.py 1.3 => 1.4 ===
 from Zope.Publisher.Browser.AttributePublisher import AttributePublisher
-from Zope.ComponentArchitecture.ContextDependent import ContextDependent
 from Zope.ComponentArchitecture import getRequestView
 
-from ZopeProducts.JobBoardEx.Job import Job
+from IJobList import IJobList
+from Job import Job
 
 
-class NewJob(AttributePublisher, ContextDependent):
+class NewJob(AttributePublisher):
+
+    __used_for__ = IJobList
+
+    def __init__(self, joblist):
+        self.joblist = joblist
+
+    def getContext(self):
+        return self.joblist
 
     index = PageTemplateFile('NewJob.pt')
 
@@ -33,7 +41,7 @@
 
     def submit(self, submitter, summary, description, contact):
         """Edits a job object."""
-        joblist = self.getContext()
+        joblist = self.joblist
         job = Job(submitter, summary, description, contact)
         joblist.add(job)
         return self.waiting(self.request)