[CMF-checkins] CVS: CMF - Topic.py:1.12

tseaver@digiciool.com tseaver@digiciool.com
Mon, 12 Mar 2001 20:48:38 -0500 (EST)


Update of /cvs-repository/CMF/CMFTopic
In directory korak:/tmp/cvs-serv29085

Modified Files:
	Topic.py 
Log Message:


 * Add 'index_html' (copy/paste from CMFCore.PortalContent?!?) so that
   topics become directly publishable (thanks to Dieter Maurer for
   pointing this out).



--- Updated File Topic.py in package CMF --
--- Topic.py	2001/03/13 01:37:45	1.11
+++ Topic.py	2001/03/13 01:48:37	1.12
@@ -88,6 +88,7 @@
 from Products.CMFCore import utils
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_parent, aq_inner
+from ComputedAttribute import ComputedAttribute
 
 # Import permission names
 from Products.CMFCore import CMFCorePermissions
@@ -151,6 +152,33 @@
 ##                       'permission'   : TopicPermissions.AddTopics,
 ##                       },
 ##                     )
+
+    # Contentish interface methods
+    # ----------------------------
+
+    def _index_html(self):
+        '''
+        Invokes the action identified by the id "view" or the first action.
+        '''
+        ti = self.getTypeInfo()
+        if ti is not None:
+            path = ti.getActionById('view', None)
+            if path is not None:
+                view = self.restrictedTraverse(path)
+                return view
+            actions = ti.getActions()
+            if actions:
+                path = actions[0]['action']
+                view = self.restrictedTraverse(path)
+                return view
+            raise 'Not Found', ('No default view defined for type "%s"'
+                                % ti.id)
+        else:
+            raise 'Not Found', ('Cannot find default view for "%s"'
+                                % self.getPhysicalPath())
+
+    security.declareProtected(CMFCorePermissions.View, 'index_html')
+    index_html = ComputedAttribute(_index_html, 1)
 
     def _criteria_metatype_ids(self):
         result = []