Back to index

plone3  3.1.7
permissions.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """ CMFCore product permissions.
00014 
00015 $Id: permissions.py 36693 2004-12-04 21:10:32Z jens $
00016 """
00017 
00018 import Products
00019 from AccessControl import ModuleSecurityInfo
00020 from AccessControl import Permissions
00021 from AccessControl.Permission import _registeredPermissions
00022 from AccessControl.Permission import pname
00023 from Globals import ApplicationDefaultPermissions
00024 
00025 
00026 security = ModuleSecurityInfo('Products.CMFCore.permissions')
00027 
00028 #
00029 # General Zope permissions
00030 #
00031 
00032 security.declarePublic('AccessContentsInformation')
00033 AccessContentsInformation = Permissions.access_contents_information
00034 
00035 security.declarePublic('ChangePermissions')
00036 ChangePermissions = Permissions.change_permissions
00037 
00038 security.declarePublic('DeleteObjects')
00039 DeleteObjects = Permissions.delete_objects
00040 
00041 security.declarePublic('FTPAccess')
00042 FTPAccess = Permissions.ftp_access
00043 
00044 security.declarePublic('ManageProperties')
00045 ManageProperties = Permissions.manage_properties
00046 
00047 security.declarePublic('ManageUsers')
00048 ManageUsers = Permissions.manage_users
00049 
00050 security.declarePublic('UndoChanges')
00051 UndoChanges = Permissions.undo_changes
00052 
00053 security.declarePublic('View')
00054 View = Permissions.view
00055 
00056 security.declarePublic('ViewManagementScreens')
00057 ViewManagementScreens = Permissions.view_management_screens
00058 
00059 security.declarePrivate('setDefaultRoles')
00060 def setDefaultRoles(permission, roles):
00061     '''
00062     Sets the defaults roles for a permission.
00063     '''
00064     # XXX This ought to be in AccessControl.SecurityInfo.
00065     registered = _registeredPermissions
00066     if not registered.has_key(permission):
00067         registered[permission] = 1
00068         Products.__ac_permissions__=(
00069             Products.__ac_permissions__+((permission,(),roles),))
00070         mangled = pname(permission)
00071         setattr(ApplicationDefaultPermissions, mangled, roles)
00072 
00073 # Note that we can only use the default Zope roles in calls to
00074 # setDefaultRoles().  The default Zope roles are:
00075 # Anonymous, Manager, and Owner.
00076 
00077 #
00078 # CMF Base Permissions
00079 #
00080 
00081 security.declarePublic('ListFolderContents')
00082 ListFolderContents = 'List folder contents'
00083 setDefaultRoles( ListFolderContents, ( 'Manager', 'Owner' ) )
00084 
00085 security.declarePublic('ListUndoableChanges')
00086 ListUndoableChanges = 'List undoable changes'
00087 setDefaultRoles( ListUndoableChanges, ('Manager',) )  # + Member
00088 
00089 security.declarePublic('AccessInactivePortalContent')
00090 AccessInactivePortalContent = 'Access inactive portal content'
00091 setDefaultRoles(AccessInactivePortalContent, ('Manager',))
00092 
00093 security.declarePublic('ModifyCookieCrumblers')
00094 ModifyCookieCrumblers = 'Modify Cookie Crumblers'
00095 setDefaultRoles(ModifyCookieCrumblers, ('Manager',))
00096 
00097 security.declarePublic('ReplyToItem')
00098 ReplyToItem = 'Reply to item'
00099 setDefaultRoles(ReplyToItem, ('Manager',))  # + Member
00100 
00101 security.declarePublic('ManagePortal')
00102 ManagePortal = 'Manage portal'
00103 setDefaultRoles(ManagePortal, ('Manager',))
00104 
00105 security.declarePublic('ModifyPortalContent')
00106 ModifyPortalContent = 'Modify portal content'
00107 setDefaultRoles(ModifyPortalContent, ('Manager',))
00108 
00109 security.declarePublic('ListPortalMembers')
00110 ListPortalMembers = 'List portal members'
00111 setDefaultRoles( ListPortalMembers, ('Manager',) )  # + Member
00112 
00113 security.declarePublic('AddPortalFolders')
00114 AddPortalFolders = 'Add portal folders'
00115 setDefaultRoles(AddPortalFolders, ('Owner','Manager'))  # + Member
00116 
00117 security.declarePublic('AddPortalContent')
00118 AddPortalContent = 'Add portal content'
00119 setDefaultRoles(AddPortalContent, ('Owner','Manager',))  # + Member
00120 
00121 security.declarePublic('AddPortalMember')
00122 AddPortalMember = 'Add portal member'
00123 setDefaultRoles(AddPortalMember, ('Anonymous', 'Manager',))
00124 
00125 security.declarePublic('SetOwnPassword')
00126 SetOwnPassword = 'Set own password'
00127 setDefaultRoles(SetOwnPassword, ('Manager',))  # + Member
00128 
00129 security.declarePublic('SetOwnProperties')
00130 SetOwnProperties = 'Set own properties'
00131 setDefaultRoles(SetOwnProperties, ('Manager',))  # + Member
00132 
00133 security.declarePublic('ChangeLocalRoles')
00134 ChangeLocalRoles = 'Change local roles'
00135 setDefaultRoles(ChangeLocalRoles, ('Owner', 'Manager'))
00136 
00137 security.declarePublic('MailForgottenPassword')
00138 MailForgottenPassword = 'Mail forgotten password'
00139 setDefaultRoles(MailForgottenPassword, ('Anonymous', 'Manager',))
00140 
00141 
00142 #
00143 # Workflow Permissions
00144 #
00145 
00146 security.declarePublic('RequestReview')
00147 RequestReview = 'Request review'
00148 setDefaultRoles(RequestReview, ('Owner', 'Manager',))
00149 
00150 security.declarePublic('ReviewPortalContent')
00151 ReviewPortalContent = 'Review portal content'
00152 setDefaultRoles(ReviewPortalContent, ('Manager',))  # + Reviewer
00153