[CMF-checkins] CVS: CMF/CMFCollector - Collector.py:1.22
Ken Manheimer
klm@zope.com
Fri, 14 Dec 2001 20:49:12 -0500
Update of /cvs-repository/CMF/CMFCollector
In directory cvs.zope.org:/tmp/cvs-serv5721
Modified Files:
Collector.py
Log Message:
Incorporating mechanism to include specific email addresses among
destinations for all notifications per issue state.
.state_email: New attribute - a dictionary which pairs state names
with email addresses, destinations for any notifications occuring
within that state.
.edit(): Set new .state_email value.
.issue_states(): Consult the workflow to get the complete list of
states.
=== CMF/CMFCollector/Collector.py 1.21 => 1.22 ===
from CollectorPermissions import *
-from CollectorIssue import addCollectorIssue
+from CollectorIssue import addCollectorIssue, CollectorIssue
INTERNAL_CATALOG_ID = 'collector_catalog'
@@ -90,6 +90,10 @@
managers = ()
dispatching = 1
+ # state_email - a dictionary pairing state names with email destinations
+ # for all notifications occuring within that state.
+ state_email = {}
+
def __init__(self, id, title='', description='', abbrev='',
email=None,
topics=None, classifications=None, importances=None,
@@ -172,7 +176,7 @@
version_info=None,
assignees=None,
file=None, fileid=None, filetype=None):
- """Instigate a new collector issue."""
+ """Create a new collector issue."""
id = self.new_issue_id()
submitter_id = str(getSecurityManager().getUser())
@@ -198,6 +202,7 @@
def edit(self, title=None, description=None,
abbrev=None, email=None,
managers=None, supporters=None, dispatching=None,
+ state_email=None,
topics=None, classifications=None,
importances=None,
version_info_spiel=None):
@@ -259,6 +264,9 @@
self.dispatching = dispatching
changes.append("Dispatching %s"
% ((dispatching and "on") or "off"))
+ if state_email is not None and self.state_email != state_email:
+ self.state_email = state_email
+ changes.append("State email")
if topics is not None:
x = filter(None, topics)
if self.topics != x:
@@ -328,6 +336,22 @@
"""For, eg, allowedRolesAndUsers recompute after local_role changes."""
for i in self.objectValues(spec='CMF Collector Issue'):
i.reindexObject(internal_only=internal_only)
+
+ security.declareProtected(ManageCollector, 'issue_states')
+ def issue_states(self):
+ """Return a sorted list of potential states for issues."""
+ # We use a stub issue (which we create, the first time) in order to
+ # get the workflow states. Kinda yucky - would be nice if the
+ # workflow provided more direct introspection.
+ got = []
+ if hasattr(self, 'stub'):
+ sample = self['stub']
+ else:
+ sample = CollectorIssue('stub', self)
+ for wf in self.portal_workflow.getWorkflowsFor(sample):
+ got.extend([x.id for x in wf.states.values()])
+ got.sort()
+ return got
security.declareProtected(CMFCorePermissions.View, 'Subject')
def Subject(self):