[Zope3-checkins] CVS: Products3/demo/messageboard/step9/browser - message.py:1.2 messageboard.py:1.2

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Aug 21 17:48:42 EDT 2003


Update of /cvs-repository/Products3/demo/messageboard/step9/browser
In directory cvs.zope.org:/tmp/cvs-serv16706/step9/browser

Modified Files:
	message.py messageboard.py 
Log Message:
Updated Step 9 updated.


=== Products3/demo/messageboard/step9/browser/message.py 1.1 => 1.2 ===
--- Products3/demo/messageboard/step9/browser/message.py:1.1	Tue Jul 15 17:43:36 2003
+++ Products3/demo/messageboard/step9/browser/message.py	Thu Aug 21 16:48:11 2003
@@ -18,8 +18,7 @@
 from zope.app.interfaces.dublincore import ICMFDublinCore
 from zopeproducts.messageboard.interfaces import IMessage, IMailSubscriptions
 
-from zope.component import getAdapter
-from zope.app.traversing import getParent, getName
+from zope.app import zapi
 from zope.app.browser.container.adding import Adding
 
 
@@ -27,16 +26,16 @@
 
     def author(self):
         """Get user who last modified the Wiki Page."""
-        creators = getAdapter(self.context, ICMFDublinCore).creators
+        creators = zapi.getAdapter(self.context, ICMFDublinCore).creators
         if not creators:
             return 'unknown'
         return creators[0]
 
     def modified(self):
         """Get last modification date."""
-        date = getAdapter(self.context, ICMFDublinCore).modified
+        date = zapi.getAdapter(self.context, ICMFDublinCore).modified
         if date is None:
-            date = getAdapter(self.context, ICMFDublinCore).created
+            date = zapi.getAdapter(self.context, ICMFDublinCore).created
         if date is None:
             return ''
         formatter = self.request.locale.getDateTimeFormatter('medium')
@@ -44,29 +43,30 @@
 
     def parent_info(self):
         """Get the parent of the message"""
-        parent = getParent(self.context)
+        parent = zapi.getParent(self.context)
         if not IMessage.isImplementedBy(parent):
             return None
-        return {'name': getName(parent), 'title': parent.title}
+        return {'name': zapi.name(parent), 'title': parent.title}
 
 
 class MailSubscriptions:
 
     def subscriptions(self):
-        return getAdapter(self.context, IMailSubscriptions).getSubscriptions()
+        return zapi.getAdapter(self.context,
+                               IMailSubscriptions).getSubscriptions()
 
     def change(self):
         if 'ADD' in self.request:
             emails = self.request['emails'].split('\n')
-            getAdapter(self.context,
-                       IMailSubscriptions).addSubscriptions(emails)
+            zapi.getAdapter(self.context,
+                            IMailSubscriptions).addSubscriptions(emails)
         elif 'REMOVE' in self.request:
             emails = self.request['remails']
             print emails
             if isinstance(emails, (str, unicode)):
                 emails = [emails]
-            getAdapter(self.context,
-                       IMailSubscriptions).removeSubscriptions(emails)
+            zapi.getAdapter(self.context,
+                            IMailSubscriptions).removeSubscriptions(emails)
 
         self.request.response.redirect('.')
 


=== Products3/demo/messageboard/step9/browser/messageboard.py 1.1 => 1.2 ===
--- Products3/demo/messageboard/step9/browser/messageboard.py:1.1	Tue Jul 15 17:43:36 2003
+++ Products3/demo/messageboard/step9/browser/messageboard.py	Thu Aug 21 16:48:11 2003
@@ -29,7 +29,7 @@
 from zope.app.traversing import getPath, getParent, traverse
 from zope.app.workflow.service import WorkflowService
 from zope.app.workflow.stateful.contentworkflow import \
-     ContentWorkflowsUtility
+     ContentWorkflowsManager
 from zope.app.workflow.service import ProcessDefinitionRegistration
 from zope.app.workflow.stateful.definition import \
      StatefulProcessDefinition
@@ -62,11 +62,7 @@
             registration = ServiceRegistration(Workflows, wf_path, site)
             wf_id = rm.setObject('', registration)
             rm[wf_id].status = ActiveStatus
-            
-            # Create Content Workflows Utility
-            default.setObject('MB-WFContent', ContentWorkflowsUtility())
-            default['MB-WFContent'].subscribe()
-            
+                        
             # Create Default Processdefinition
             default.setObject('MB-WFProcesses',
                               StatefulProcessDefinition())
@@ -84,6 +80,12 @@
             import_util.importProcessDefinition(
                 default['MB-WFProcesses'], open(xml, mode='r'))
 
+            # Create Content Workflows Manager
+            default.setObject('MB-WFContent', ContentWorkflowsManager())
+            content = traverse(default, 'MB-WFContent')
+            content.subscribe()
+            content.register(IMessage, 'publish-message')
+
         return content
     
 
@@ -113,7 +115,7 @@
         return msg_infos
 
 
-def hasMessageStatus(msg, status, workflow='default'):
+def hasMessageStatus(msg, status, workflow='publish-message'):
     """Check whether a particular message matches a given status"""
     adapter = queryAdapter(msg, IProcessInstanceContainer)
     if adapter:




More information about the Zope3-Checkins mailing list