[CMF-checkins] CVS: CMF/CMFDefault - DefaultWorkflow.py:1.20 DiscussionTool.py:1.15 MembershipTool.py:1.37 Portal.py:1.36 RegistrationTool.py:1.21

Yvo Schubbe schubbe at web.de
Mon Sep 1 12:19:06 EDT 2003


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

Modified Files:
	DefaultWorkflow.py DiscussionTool.py MembershipTool.py 
	Portal.py RegistrationTool.py 
Log Message:
Permissions cleanup

=== CMF/CMFDefault/DefaultWorkflow.py 1.19 => 1.20 ===
--- CMF/CMFDefault/DefaultWorkflow.py:1.19	Fri Mar 14 12:12:06 2003
+++ CMF/CMFDefault/DefaultWorkflow.py	Mon Sep  1 11:18:36 2003
@@ -20,13 +20,16 @@
 from DateTime import DateTime
 from Globals import InitializeClass
 
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
+from Products.CMFCore.CMFCorePermissions import RequestReview
+from Products.CMFCore.CMFCorePermissions import ReviewPortalContent
+from Products.CMFCore.CMFCorePermissions import View
 from Products.CMFCore.utils import _modifyPermissionMappings
 from Products.CMFCore.utils import _checkPermission
 from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.utils import SimpleItemWithProperties
 from Products.CMFCore.WorkflowCore import WorkflowException
 from Products.CMFCore.WorkflowTool import addWorkflowClass
-from Products.CMFCore.CMFCorePermissions import ReviewPortalContent
 
 from Products.CMFCore.interfaces.portal_workflow \
         import WorkflowDefinition as IWorkflowDefinition
@@ -94,8 +97,8 @@
         review_state = self.getReviewStateOf(content)
         actions = []
 
-        allow_review = _checkPermission('Review portal content', content)
-        allow_request = _checkPermission('Request review', content)
+        allow_review = _checkPermission(ReviewPortalContent, content)
+        allow_request = _checkPermission(RequestReview, content)
 
         append_action = (lambda name, p, url=content_url, a=actions.append:
                          a({'name': name,
@@ -173,8 +176,8 @@
         Allows the user to request a workflow action.  This method
         must perform its own security checks.
         '''
-        allow_review = _checkPermission('Review portal content', ob)
-        allow_request = _checkPermission('Request review', ob)
+        allow_review = _checkPermission(ReviewPortalContent, ob)
+        allow_request = _checkPermission(RequestReview, ob)
         review_state = self.getReviewStateOf(ob)
         tool = aq_parent(aq_inner(self))
 
@@ -224,8 +227,8 @@
         if name == 'review_state':
             return self.getReviewStateOf(ob)
 
-        allow_review = _checkPermission('Review portal content', ob)
-        allow_request = _checkPermission('Request review', ob)
+        allow_review = _checkPermission(ReviewPortalContent, ob)
+        allow_request = _checkPermission(RequestReview, ob)
         if not allow_review and not allow_request:
             return default
 
@@ -309,11 +312,10 @@
 
         # Modify role to permission mappings directly.
 
-        new_map = { 'View': { 'Anonymous': anon_view
-                            , 'Reviewer': reviewer_view
-                            , 'Owner': 1
-                            }
-                  , 'Modify portal content': {'Owner': owner_modify}
+        new_map = { View: {'Anonymous': anon_view,
+                           'Reviewer': reviewer_view,
+                           'Owner': 1}
+                  , ModifyPortalContent: {'Owner': owner_modify}
                   }
         return _modifyPermissionMappings(ob, new_map)
 


=== CMF/CMFDefault/DiscussionTool.py 1.14 => 1.15 ===
--- CMF/CMFDefault/DiscussionTool.py:1.14	Thu Feb 13 02:46:21 2003
+++ CMF/CMFDefault/DiscussionTool.py	Mon Sep  1 11:18:36 2003
@@ -22,6 +22,7 @@
 from Products.CMFCore.utils import UniqueObject, getToolByName
 from Products.CMFCore.CMFCorePermissions import ManagePortal
 from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
+from Products.CMFCore.CMFCorePermissions import ReplyToItem
 
 from utils import _dtmldir
 from DiscussionItem import DiscussionItemContainer
@@ -49,7 +50,7 @@
                                 , condition=Expression(
                 text='python: object is not None and ' +
                 'portal.portal_discussion.isDiscussionAllowedFor(object)')
-                                , permissions=('Reply to item',)
+                                , permissions=(ReplyToItem,)
                                 , category='object'
                                 , visible=1
                                  )


=== CMF/CMFDefault/MembershipTool.py 1.36 => 1.37 ===
--- CMF/CMFDefault/MembershipTool.py:1.36	Mon Jun  2 12:18:48 2003
+++ CMF/CMFDefault/MembershipTool.py	Mon Sep  1 11:18:36 2003
@@ -154,7 +154,7 @@
         If Manager, return a list of all usernames.  The mapping
         contains the id and listed variables.
         """
-        isManager = _checkPermission('Manage portal', self)
+        isManager = _checkPermission(ManagePortal, self)
         roster = []
         for member in self.listMembers():
             if isManager or member.listed:
@@ -255,7 +255,7 @@
         if members:
             try:
                 folder = members[id]
-                if verifyPermission and not _checkPermission('View', folder):
+                if verifyPermission and not _checkPermission(View, folder):
                     # Don't return the folder if the user can't get to it.
                     return None
                 return folder


=== CMF/CMFDefault/Portal.py 1.35 => 1.36 ===
--- CMF/CMFDefault/Portal.py:1.35	Thu Feb 13 03:35:28 2003
+++ CMF/CMFDefault/Portal.py	Mon Sep  1 11:18:36 2003
@@ -18,6 +18,22 @@
 from Globals import HTMLFile
 from Globals import InitializeClass
 
+from Products.CMFCore.CMFCorePermissions import AccessFuturePortalContent
+from Products.CMFCore.CMFCorePermissions import AddPortalContent
+from Products.CMFCore.CMFCorePermissions import AddPortalFolders
+from Products.CMFCore.CMFCorePermissions import DeleteObjects
+from Products.CMFCore.CMFCorePermissions import FTPAccess
+from Products.CMFCore.CMFCorePermissions import ListPortalMembers
+from Products.CMFCore.CMFCorePermissions import ListUndoableChanges
+from Products.CMFCore.CMFCorePermissions import ManagePortal
+from Products.CMFCore.CMFCorePermissions import ManageProperties
+from Products.CMFCore.CMFCorePermissions import ReplyToItem
+from Products.CMFCore.CMFCorePermissions import ReviewPortalContent
+from Products.CMFCore.CMFCorePermissions import SetOwnPassword
+from Products.CMFCore.CMFCorePermissions import SetOwnProperties
+from Products.CMFCore.CMFCorePermissions import UndoChanges
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ViewManagementScreens
 from Products.CMFCore.PortalObject import PortalObjectBase
 from Products.CMFCore import PortalFolder
 from Products.CMFCore.TypesTool import ContentFactoryMetadata
@@ -55,12 +71,12 @@
     title = ''
     description = ''
 
-    __ac_permissions__=( ( 'Manage portal', ('manage_migrate_content',) )
-                       , ( 'Add portal content', () )
-                       , ( 'Add portal folders', () )
-                       , ( 'List portal members', () )
-                       , ( 'Reply to item', () )
-                       , ( 'View',  ( 'isEffective', ) )
+    __ac_permissions__=( ( ManagePortal, ('manage_migrate_content',) )
+                       , ( AddPortalContent, () )
+                       , ( AddPortalFolders, () )
+                       , ( ListPortalMembers, () )
+                       , ( ReplyToItem, () )
+                       , ( View, ('isEffective',) )
                        )
 
     def __init__( self, id, title='' ):
@@ -203,23 +219,22 @@
         # Set up some suggested role to permission mappings.
         mp = p.manage_permission
 
-        mp('Set own password',        ['Member','Manager',],    1)
-        mp('Set own properties',      ['Member','Manager',],    1)
-        mp('List undoable changes',   ['Member','Manager',],    1)
-        mp('Add portal content',      ['Owner','Manager',],     1)
-        mp('Add portal folders',      ['Owner','Manager',],     1)
-        mp('Review portal content',   ['Reviewer','Manager',],  1)
-        mp('Access future portal content',
-                                      ['Reviewer','Manager',],  1)
-        mp('List portal members',     ['Member','Manager',],    1)
-        mp('Reply to item',           ['Member','Manager',],    1)
+        mp(AccessFuturePortalContent, ['Reviewer','Manager',], 1)
+        mp(AddPortalContent,          ['Owner','Manager',],    1)
+        mp(AddPortalFolders,          ['Owner','Manager',],    1)
+        mp(ListPortalMembers,         ['Member','Manager',],   1)
+        mp(ListUndoableChanges,       ['Member','Manager',],   1)
+        mp(ReplyToItem,               ['Member','Manager',],   1)
+        mp(ReviewPortalContent,       ['Reviewer','Manager',], 1)
+        mp(SetOwnPassword,            ['Member','Manager',],   1)
+        mp(SetOwnProperties,          ['Member','Manager',],   1)
 
         # Add some other permissions mappings that may be helpful.
-        mp('Delete objects',          ['Owner','Manager',],     1)
-        mp('FTP access',              ['Owner','Manager',],     1)
-        mp('Manage properties',       ['Owner','Manager',],     1)
-        mp('Undo changes',            ['Owner','Manager',],     1)
-        mp('View management screens', ['Owner','Manager',],     1)
+        mp(DeleteObjects,             ['Owner','Manager',],    1)
+        mp(FTPAccess,                 ['Owner','Manager',],    1)
+        mp(ManageProperties,          ['Owner','Manager',],    1)
+        mp(UndoChanges,               ['Owner','Manager',],    1)
+        mp(ViewManagementScreens,     ['Owner','Manager',],    1)
 
     def setupDefaultSkins(self, p):
         from Products.CMFCore.DirectoryView import addDirectoryViews


=== CMF/CMFDefault/RegistrationTool.py 1.20 => 1.21 ===
--- CMF/CMFDefault/RegistrationTool.py:1.20	Sat May  3 21:16:44 2003
+++ CMF/CMFDefault/RegistrationTool.py	Mon Sep  1 11:18:36 2003
@@ -76,7 +76,7 @@
         o If the password is valid, return None.
         o If not, return a string explaining why.
         """
-        if len(password) < 5 and not _checkPermission('Manage portal', self):
+        if len(password) < 5 and not _checkPermission(ManagePortal, self):
             return 'Your password must contain at least 5 characters.'
 
         if confirm is not None and confirm != password:




More information about the CMF-checkins mailing list