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

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


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

Modified Files:
	message.py messageboard.py 
Log Message:
Updated Step 8


=== Products3/demo/messageboard/step8/browser/message.py 1.1 => 1.2 ===
--- Products3/demo/messageboard/step8/browser/message.py:1.1	Mon Jul 14 20:01:06 2003
+++ Products3/demo/messageboard/step8/browser/message.py	Thu Aug 21 16:16:33 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,16 +43,17 @@
 
     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:
@@ -65,8 +65,8 @@
             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/step8/browser/messageboard.py 1.2 => 1.3 ===
--- Products3/demo/messageboard/step8/browser/messageboard.py:1.2	Tue Jul 15 06:29:40 2003
+++ Products3/demo/messageboard/step8/browser/messageboard.py	Thu Aug 21 16:16:33 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,17 +62,13 @@
             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())
             pd_path = getPath(traverse(default, 'MB-WFProcesses'))
             registration = ProcessDefinitionRegistration(
-                'default', pd_path)
+                'publish-message', pd_path)
             pd_id = rm.setObject('', registration)
             traverse(rm, pd_id).status = ActiveStatus
             
@@ -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