[CMF-checkins] CVS: CMF/CMFDefault - DiscussionTool.py:1.6.12.1 MembershipTool.py:1.17.12.1 MetadataTool.py:1.9.12.1 RegistrationTool.py:1.8.8.1 SyndicationTool.py:1.9.12.1 URLTool.py:1.7.12.1

Andrew Sawyers andrew@zope.com
Wed, 2 Jan 2002 17:03:35 -0500


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv20833/CMFDefault

Modified Files:
      Tag: andrew_ttw_actions-branch
	DiscussionTool.py MembershipTool.py MetadataTool.py 
	RegistrationTool.py SyndicationTool.py URLTool.py 
Log Message:

*Changes to support Tools TTW Actions
*Changes to support TTW Action Provider configuration
*Docs and Test coming soon...


=== CMF/CMFDefault/DiscussionTool.py 1.6 => 1.6.12.1 ===
 from utils import _dtmldir
 from DiscussionItem import DiscussionItemContainer
+from Products.CMFCore.ActionInformation import ActionInformation
+from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.Expression import Expression
 
 class DiscussionNotAllowed( Exception ):
     pass
 
-class DiscussionTool( UniqueObject, SimpleItem ):
+class DiscussionTool( UniqueObject, SimpleItem, ActionProviderBase ):
 
     id = 'portal_discussion'
     meta_type = 'Default Discussion Tool'
+    _actions = [ActionInformation(id='reply'
+                                , title='Reply'
+                                , action=Expression(
+                text='string: ${object_url}/discussion_reply_form')
+                                , condition=Expression(
+                text='python: object is not None and ' +
+                'portal.portal_discussion.isDiscussionAllowedFor(object)')
+                                , permissions=('Reply to item',)
+                                , category='object'
+                                , visible=1
+                                 )]
 
     security = ClassSecurityInfo()
 
-    manage_options = ( { 'label' : 'Overview', 'action' : 'manage_overview' }
+    manage_options = (ActionProviderBase.manage_options +
+                     ({ 'label' : 'Overview', 'action' : 'manage_overview' }
                      , 
-                     ) + SimpleItem.manage_options
+                     ) + SimpleItem.manage_options)
 
     #
     #   ZMI methods
@@ -52,6 +67,13 @@
     #   'portal_discussion' interface methods
     #
 
+    security.declarePrivate('listActions')
+    def listActions(self, info=None):
+        """
+        Return available actions via tool.
+        """
+        return self._actions
+
     security.declarePublic( 'overrideDiscussionFor' )
     def overrideDiscussionFor(self, content, allowDiscussion):
         """
@@ -96,29 +118,6 @@
         if typeInfo:
             return typeInfo.allowDiscussion()
         return 0
-
-    #
-    #   ActionProvider interface
-    #
-    security.declarePrivate( 'listActions' )
-    def listActions(self, info):
-        # Return actions for reply and show replies
-        content = info.content
-        if content is None or not self.isDiscussionAllowedFor(content):
-            return None
-
-        discussion = self.getDiscussionFor(content)
-        discussion_url = info.content_url
-
-        actions = (
-            {'name': 'Reply',
-             'url': discussion_url + '/discussion_reply_form',
-             'permissions': ['Reply to item'],
-             'category': 'object'
-             },
-            )
-
-        return actions
 
     #
     #   Utility methods


=== CMF/CMFDefault/MembershipTool.py 1.17 => 1.17.12.1 ===
 from Products.CMFCore.utils import _getAuthenticatedUser, _checkPermission
 from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.ActionsTool import ActionInformation
 import Products.CMFCore.MembershipTool
 from Products.CMFCore.PortalFolder import manage_addPortalFolder
 import Document
 
 from Globals import InitializeClass, DTMLFile
 from AccessControl import ClassSecurityInfo
+from Products.CMFCore.Expression import Expression
 from Products.CMFCore.CMFCorePermissions import View, AccessContentsInformation
 from Products.CMFCore.CMFCorePermissions import ListPortalMembers, AddPortalMember
 from Products.CMFCore.CMFCorePermissions import ManagePortal
@@ -40,10 +42,92 @@
   in the Tool Box on the left.
 '''
 
-
 class MembershipTool ( Products.CMFCore.MembershipTool.MembershipTool ):
     """
     """
+    _actions =[ActionInformation(id='join'
+                            , title='Join'
+                            , description='Click here to Join'
+                            , action=Expression(
+            text='string: ${portal_url}/join_form')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(text='not: member')
+                            , visible=1
+                             )
+          , ActionInformation(id='login'
+                            , title='Login'
+                            , description='Click here to Login'
+                            , action=Expression(
+            text='string: ${portal_url}/login_form')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(text='not: member')
+                            , visible=1
+                             ) 
+          , ActionInformation(id='preferences'
+                            , title='Preferences'
+                            , description='Change your user preferences'
+                            , action=Expression(
+            text='string: ${portal_url}/personalize_form')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(text='member')
+                            , visible=1
+                             )
+          , ActionInformation(id='logout'
+                            , title='Log out'
+                            , description='Click here to logout'
+                            , action=Expression(
+            text='string: ${portal_url}/logout')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(text='member')
+                            , visible=1
+                             )
+          , ActionInformation(id='configPortal'
+                            , title='Reconfigure Portal'
+                            , description='Reconfigure the portal'
+                            , action=Expression(
+            text='string: ${portal_url}/reconfig_form')
+                            , permissions=(ManagePortal,)
+                            , category='global'
+                            , condition=None
+                            , visible=1
+                             )
+          , ActionInformation(id='addFavorite'
+                            , title='Add to favorites'
+                            , description='Add this item to your favorites'
+                            , action=Expression(
+            text='string: ${portal_url}/addtoFavorites')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(
+            text='python: portal.portal_membership.getHomeFolder()')
+                            , visible=1
+                             )
+          , ActionInformation(id='mystuff'
+                            , title='my stuff'
+                            , description='Goto your home folder'
+                            , action=Expression(text='member/getHomeUrl')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(
+           text='python: member and portal.portal_membership.getHomeFolder()')
+                            , visible=1
+                             )
+          , ActionInformation(id='favorites'
+                            , title='My favorites'
+                            , description='Browser your favorites'
+                            , action=Expression(
+           text='python: member.getHomeUrl() + \'/Favorites/folder_contents\'')
+                            , permissions=(View,)
+                            , category='user'
+                            , condition=Expression(
+           text='python: member and hasattr(portal.portal_membership.getHomeFolder(), \'Favorites\')')
+                            , visible=1
+                             )
+                           ]
 
     meta_type = 'Default Membership Tool'
 
@@ -151,63 +235,8 @@
             return None
 
     security.declarePrivate( 'listActions' )
-    def listActions(self, info):
-        '''Lists actions available to the user.'''
-        user_actions = None
-        portal_url = info.portal_url
-        if info.isAnonymous:
-            user_actions = (
-                {'name': 'Log in',
-                 'url': portal_url + '/login_form',
-                 'permissions': [],
-                 'category': 'user'},
-                {'name': 'Join',
-                 'url': portal_url + '/join_form',
-                 'permissions': [AddPortalMember],
-                 'category': 'user'},
-                )
-
-        if not info.isAnonymous:
-            home_folder = self.getHomeFolder()
-            homeUrl = self.getHomeUrl()
-            user_actions = (
-                {'name': 'Preferences',
-                 'url': portal_url + '/personalize_form',
-                 'permissions': [],
-                 'category': 'user'},
-                {'name': 'Log out',
-                 'url': portal_url + '/logout',
-                 'permissions' : [],
-                 'category': 'user'},
-                {'name': 'Reconfigure portal',
-                 'url': portal_url + '/reconfig_form',
-                 'permissions': ['Manage portal'],
-                 'category': 'global'},
-                )
-
-            if homeUrl is not None:
-                content_url = info.content_url
-                actions = (
-                    {'name': 'Add to Favorites',
-                     'url': ( content_url + '/addtoFavorites' ),
-                     'permissions' : [],
-                     'category': 'user'},
-                    {'name': 'My Stuff',
-                     'url': homeUrl + '/folder_contents',
-                     'permissions': [],
-                     'category': 'user'},
-                    )
-                user_actions = user_actions + actions
-
-                if hasattr( home_folder, 'Favorites' ):
-                    added_actions = (
-                      {'name': 'My Favorites',
-                       'url' : homeUrl + '/Favorites/folder_contents',
-                       'permissions': [],
-                       'category': 'user'},) 
-                    user_actions = user_actions + added_actions
-                    
-        return user_actions
-
+    def listActions(self, info=None):
+        '''Lists actions available through the tool.'''
+        return self._actions
 
 InitializeClass(MembershipTool)


=== CMF/CMFDefault/MetadataTool.py 1.9 => 1.9.12.1 ===
 from AccessControl import ClassSecurityInfo, getSecurityManager
 from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.ActionProviderBase import ActionProviderBase
 from utils import _dtmldir
 
 class MetadataElementPolicy( Persistent ):
@@ -190,11 +191,13 @@
 class MetadataError( Exception ):
     pass
 
-class MetadataTool( UniqueObject, SimpleItem ):
+class MetadataTool( UniqueObject, SimpleItem, ActionProviderBase ):
 
     id              = 'portal_metadata'
     meta_type       = 'Default Metadata Tool'
 
+    _actions = []
+
     security = ClassSecurityInfo()
 
     #
@@ -225,7 +228,8 @@
     #
     #   ZMI methods
     #
-    manage_options = ( ( { 'label'      : 'Overview'
+    manage_options = ( ActionProviderBase.manage_options + 
+                     ( { 'label'      : 'Overview'
                          , 'action'     : 'manage_overview'
                          }
                        , { 'label'      : 'Properties'
@@ -248,6 +252,13 @@
     security.declareProtected( CMFCorePermissions.ManagePortal
                              , 'propertiesForm' )
     propertiesForm = DTMLFile( 'metadataProperties', _dtmldir )
+
+    security.declarePrivate('listActions')
+    def listActions(self, info=None):
+        """
+        Return actions provided via tool.
+        """
+        return self._actions
 
     security.declareProtected( CMFCorePermissions.ManagePortal
                              , 'editProperties' )


=== CMF/CMFDefault/RegistrationTool.py 1.8 => 1.8.8.1 ===
 from Products.CMFCore.utils import UniqueObject
 from Products.CMFCore.utils import _checkPermission, getToolByName
+from Products.CMFCore.ActionProviderBase import ActionProviderBase
 from Products.CMFCore.RegistrationTool import RegistrationTool
 
 from Globals import InitializeClass, DTMLFile
@@ -27,9 +28,11 @@
 from Products.CMFCore import CMFCorePermissions
 from utils import _dtmldir
 
-class RegistrationTool (RegistrationTool):
+class RegistrationTool (RegistrationTool, ActionProviderBase):
     meta_type = 'Default Registration Tool'
 
+    _actions = []
+
     security = ClassSecurityInfo()
 
     #
@@ -37,6 +40,11 @@
     #
     security.declareProtected( CMFCorePermissions.ManagePortal
                              , 'manage_overview' )
+
+    manage_options = ( ActionProviderBase.manage_options +
+                       ({ 'label' : 'Overview', 'action' : 'manage_overview' }
+                     , 
+                     ))
     manage_overview = DTMLFile( 'explainRegistrationTool', _dtmldir )
 
     #
@@ -55,10 +63,11 @@
         return None
 
     security.declarePublic('listActions')
-    def listActions(self, info):
+    def listActions(self, info=None):
         """
+        Return actions provided via tool.
         """
-        return None
+        return self._actions 
 
     security.declarePublic( 'testPropertiesValidity' )
     def testPropertiesValidity(self, props, member=None):


=== CMF/CMFDefault/SyndicationTool.py 1.9 => 1.9.12.1 ===
 from Products.CMFCore.CMFCorePermissions import ManageProperties
 from Products.CMFCore.CMFCorePermissions import AccessContentsInformation
+from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.ActionInformation import ActionInformation
+from Products.CMFCore.Expression import Expression
 import Products.CMFCore.CMFCorePermissions
 from Products.CMFCore.PortalFolder import PortalFolder
 from SyndicationInfo import SyndicationInformation
 
 _dtmldir = os.path.join( package_home( globals() ), 'dtml' )
 
-class SyndicationTool (UniqueObject, SimpleItem):
+class SyndicationTool (UniqueObject, SimpleItem, ActionProviderBase):
     id = 'portal_syndication'
     meta_type = 'Default Syndication Tool'
 
+    _actions = [ActionInformation(id='syndication'
+                                , title='Syndication'
+                                , action=Expression(
+               text='string: ${folder_url}/synPropertiesForm')
+                                , condition=Expression(
+               text='python: folder is object') 
+                                , permissions=(ManageProperties,)
+                                , category='folder'
+                                , visible=1
+                                 )]
+
     security = ClassSecurityInfo()
     
     #Default Sitewide Values
@@ -46,7 +60,8 @@
     max_items = 15
 
     #ZMI Methods
-    manage_options = (({'label'     :  'Overview'
+    manage_options = (ActionProviderBase.manage_options + 
+                        ({'label'     :  'Overview'
                         ,'action'   :  'overview'
                         , 'help'    :  ('CMFDefault', 'Syndication-Tool_Overview.stx') }
                         ,{'label'   :  'Properties'
@@ -69,6 +84,13 @@
     security.declareProtected(ManagePortal, 'reportForm')
     reportForm = HTMLFile('synReports', _dtmldir)
    
+    security.declarePrivate('listActions')
+    def listActions(self, info=None):
+        """
+        Return actions provided by tool
+        """
+        return self._actions
+
     security.declareProtected(ManagePortal, 'editProperties')
     def editProperties(self
                        , updatePeriod=None


=== CMF/CMFDefault/URLTool.py 1.7 => 1.7.12.1 ===
     security = ClassSecurityInfo()
 
-    manage_options = ( { 'label' : 'Overview', 'action' : 'manage_overview' }
+    manage_options = ( { 'label' : 'Overview', 'action' : 'manage_overview' } 
                      , 
                      ) + SimpleItem.manage_options