[CMF-checkins] SVN: CMF/branches/2.1/ - cleaned up postonly fixes
Yvo Schubbe
y.2007- at wcm-solutions.de
Thu Jun 28 13:25:28 EDT 2007
Log message for revision 77182:
- cleaned up postonly fixes
Changed:
U CMF/branches/2.1/CMFCore/MembershipTool.py
U CMF/branches/2.1/CMFCore/RegistrationTool.py
U CMF/branches/2.1/CMFCore/WorkflowTool.py
U CMF/branches/2.1/CMFCore/utils.py
U CMF/branches/2.1/CMFDefault/RegistrationTool.py
U CMF/branches/2.1/DCWorkflow/States.py
U CMF/branches/2.1/DCWorkflow/WorkflowUIMixin.py
-=-
Modified: CMF/branches/2.1/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/MembershipTool.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/CMFCore/MembershipTool.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -18,6 +18,7 @@
from warnings import warn
from AccessControl import ClassSecurityInfo
+from AccessControl.requestmethod import postonly
from AccessControl.User import nobody
from Acquisition import aq_base
from Acquisition import aq_inner
@@ -49,9 +50,7 @@
from utils import _getAuthenticatedUser
from utils import getToolByName
from utils import UniqueObject
-from utils import postonly
-
logger = logging.getLogger('CMFCore.MembershipTool')
@@ -93,6 +92,7 @@
manage_mapRoles = DTMLFile('membershipRolemapping', _dtmldir )
security.declareProtected(SetOwnPassword, 'setPassword')
+ @postonly
def setPassword(self, password, domains=None, REQUEST=None):
'''Allows the authenticated member to set his/her own password.
'''
@@ -108,7 +108,6 @@
member.setSecurityProfile(password=password, domains=domains)
else:
raise BadRequest('Not logged in.')
- setPassword = postonly(setPassword)
security.declarePublic('getAuthenticatedMember')
def getAuthenticatedMember(self):
@@ -175,6 +174,7 @@
return roles
security.declareProtected(ManagePortal, 'setRoleMapping')
+ @postonly
def setRoleMapping(self, portal_role, userfolder_role, REQUEST=None):
"""
set the mapping of roles between roles understood by
@@ -191,7 +191,6 @@
title ='Mapping updated',
message='The Role mappings have been updated',
action ='manage_mapRoles')
- setRoleMapping = postonly(setRoleMapping)
security.declareProtected(ManagePortal, 'getMappedRole')
def getMappedRole(self, portal_role):
@@ -292,6 +291,7 @@
createMemberarea = createMemberArea
security.declareProtected(ManageUsers, 'deleteMemberArea')
+ @postonly
def deleteMemberArea(self, member_id, REQUEST=None):
""" Delete member area of member specified by member_id.
"""
@@ -303,7 +303,6 @@
return 1
else:
return 0
- deleteMemberArea = postonly(deleteMemberArea)
security.declarePublic('isAnonymousUser')
def isAnonymousUser(self):
@@ -442,6 +441,7 @@
return tuple(local_roles)
security.declareProtected(View, 'setLocalRoles')
+ @postonly
def setLocalRoles(self, obj, member_ids, member_role, reindex=1,
REQUEST=None):
""" Add local roles on an item.
@@ -460,9 +460,9 @@
# reindexObjectSecurity, which is in CMFCatalogAware and
# thus PortalContent and PortalFolder.
obj.reindexObjectSecurity()
- setLocalRoles = postonly(setLocalRoles)
security.declareProtected(View, 'deleteLocalRoles')
+ @postonly
def deleteLocalRoles(self, obj, member_ids, reindex=1, recursive=0,
REQUEST=None):
""" Delete local roles of specified members.
@@ -480,7 +480,6 @@
if reindex:
# reindexObjectSecurity is always recursive
obj.reindexObjectSecurity()
- deleteLocalRoles = postonly(deleteLocalRoles)
security.declarePrivate('addMember')
def addMember(self, id, password, roles, domains, properties=None):
@@ -503,6 +502,7 @@
member.setMemberProperties(properties)
security.declareProtected(ManageUsers, 'deleteMembers')
+ @postonly
def deleteMembers(self, member_ids, delete_memberareas=1,
delete_localroles=1, REQUEST=None):
""" Delete members specified by member_ids.
@@ -545,7 +545,6 @@
reindex=1, recursive=1 )
return tuple(member_ids)
- deleteMembers = postonly(deleteMembers)
security.declarePublic('getHomeFolder')
def getHomeFolder(self, id=None, verifyPermission=0):
Modified: CMF/branches/2.1/CMFCore/RegistrationTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/RegistrationTool.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/CMFCore/RegistrationTool.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -19,6 +19,7 @@
from random import choice
from AccessControl import ClassSecurityInfo
+from AccessControl.requestmethod import postonly
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
@@ -36,7 +37,6 @@
from utils import getToolByName
from utils import Message as _
from utils import UniqueObject
-from utils import postonly
class RegistrationTool(UniqueObject, SimpleItem):
@@ -132,6 +132,7 @@
return ''.join( [ choice(chars) for i in range(6) ] )
security.declareProtected(AddPortalMember, 'addMember')
+ @postonly
def addMember(self, id, password, roles=('Member',), domains='',
properties=None, REQUEST=None):
'''Creates a PortalMember and returns it. The properties argument
@@ -167,7 +168,6 @@
member = membership.getMemberById(id)
self.afterAdd(member, id, password, properties)
return member
- addMember = postonly(addMember)
security.declareProtected(AddPortalMember, 'isMemberIdAllowed')
def isMemberIdAllowed(self, id):
Modified: CMF/branches/2.1/CMFCore/WorkflowTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/WorkflowTool.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/CMFCore/WorkflowTool.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -19,6 +19,7 @@
from warnings import warn
from AccessControl import ClassSecurityInfo
+from AccessControl.requestmethod import postonly
from Acquisition import aq_base, aq_inner, aq_parent
from Globals import DTMLFile
from Globals import InitializeClass
@@ -38,7 +39,6 @@
from utils import getToolByName
from utils import Message as _
from utils import UniqueObject
-from utils import postonly
from WorkflowCore import ActionRaisedExceptionEvent
from WorkflowCore import ActionSucceededEvent
from WorkflowCore import ActionWillBeInvokedEvent
@@ -110,8 +110,8 @@
manage_tabs_message=manage_tabs_message)
security.declareProtected( ManagePortal, 'manage_changeWorkflows')
+ @postonly
def manage_changeWorkflows(self, default_chain, props=None, REQUEST=None):
-
""" Changes which workflows apply to objects of which type.
"""
if props is None:
@@ -153,7 +153,6 @@
if REQUEST is not None:
return self.manage_selectWorkflows(REQUEST,
manage_tabs_message='Changed.')
- manage_changeWorkflows = postonly(manage_changeWorkflows)
#
# 'IActionProvider' interface methods
@@ -361,6 +360,7 @@
# 'IConfigurableWorkflowTool' interface methods
#
security.declareProtected(ManagePortal, 'setDefaultChain')
+ @postonly
def setDefaultChain(self, default_chain, REQUEST=None):
""" Set the default chain for this tool.
"""
@@ -373,9 +373,9 @@
ids.append(wf_id)
self._default_chain = tuple(ids)
- setDefaultChain = postonly(setDefaultChain)
security.declareProtected(ManagePortal, 'setChainForPortalTypes')
+ @postonly
def setChainForPortalTypes(self, pt_names, chain, verify=True,
REQUEST=None):
""" Set a chain for specific portal types.
@@ -402,7 +402,6 @@
if verify and not (type_id in ti_ids):
continue
cbt[type_id] = tuple(chain)
- setChainForPortalTypes = postonly(setChainForPortalTypes)
security.declarePrivate('getDefaultChain')
def getDefaultChain(self):
@@ -445,6 +444,7 @@
# Other methods
#
security.declareProtected(ManagePortal, 'updateRoleMappings')
+ @postonly
def updateRoleMappings(self, REQUEST=None):
""" Allow workflows to update the role-permission mappings.
"""
@@ -460,7 +460,6 @@
'%d object(s) updated.' % count)
else:
return count
- updateRoleMappings = postonly(updateRoleMappings)
security.declarePrivate('getWorkflowById')
def getWorkflowById(self, wf_id):
Modified: CMF/branches/2.1/CMFCore/utils.py
===================================================================
--- CMF/branches/2.1/CMFCore/utils.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/CMFCore/utils.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -932,14 +932,3 @@
security.declarePublic('Message')
Message = MessageFactory('cmf_default')
-
-# postonly decorator is only available in Zope 2.8.9, 2.9.7, 2.10.3 and 2.11,
-# or in Hotfix_20070320.
-try:
- from AccessControl.requestmethod import postonly
-except ImportError:
- try:
- from Products.Hotfix_20070320 import postonly
- except ImportError:
- def postonly(callable):
- return callable
Modified: CMF/branches/2.1/CMFDefault/RegistrationTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/RegistrationTool.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/CMFDefault/RegistrationTool.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -18,6 +18,7 @@
from warnings import warn
from AccessControl import ClassSecurityInfo
+from AccessControl.requestmethod import postonly
from Acquisition import aq_base
from Globals import InitializeClass
from Products.MailHost.interfaces import IMailHost
@@ -28,7 +29,6 @@
from Products.CMFCore.RegistrationTool import RegistrationTool as BaseTool
from Products.CMFCore.utils import _checkPermission
from Products.CMFCore.utils import getToolByName
-from Products.CMFCore.utils import postonly
from permissions import ManagePortal
from utils import checkEmailAddress
@@ -198,6 +198,7 @@
host.send( mail_text )
security.declareProtected(ManagePortal, 'editMember')
+ @postonly
def editMember(self, member_id, properties=None, password=None,
roles=None, domains=None, REQUEST=None):
""" Edit a user's properties and security settings
@@ -213,6 +214,5 @@
member.setSecurityProfile(password,roles,domains)
return member
- editMember = postonly(editMember)
InitializeClass(RegistrationTool)
Modified: CMF/branches/2.1/DCWorkflow/States.py
===================================================================
--- CMF/branches/2.1/DCWorkflow/States.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/DCWorkflow/States.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -16,6 +16,7 @@
"""
from AccessControl import ClassSecurityInfo
+from AccessControl.requestmethod import postonly
from Acquisition import aq_inner
from Acquisition import aq_parent
from Globals import DTMLFile
@@ -27,7 +28,6 @@
from ContainerTab import ContainerTab
from permissions import ManagePortal
from utils import _dtmldir
-from Products.CMFCore.utils import postonly
class StateDefinition(SimpleItem):
@@ -197,6 +197,7 @@
manage_tabs_message=manage_tabs_message,
)
+ @postonly
def setPermissions(self, REQUEST):
"""Set the permissions in REQUEST for this State."""
pr = self.permission_roles
@@ -214,8 +215,8 @@
roles = tuple(roles)
pr[p] = roles
return self.manage_permissions(REQUEST, 'Permissions changed.')
- setPermissions = postonly(setPermissions)
+ @postonly
def setPermission(self, permission, acquired, roles, REQUEST=None):
"""Set a permission for this State."""
pr = self.permission_roles
@@ -226,10 +227,10 @@
else:
roles = tuple(roles)
pr[permission] = roles
- setPermission = postonly(setPermission)
manage_groups = PageTemplateFile('state_groups.pt', _dtmldir)
+ @postonly
def setGroups(self, REQUEST, RESPONSE=None):
"""Set the group to role mappings in REQUEST for this State.
"""
@@ -250,7 +251,6 @@
RESPONSE.redirect(
"%s/manage_groups?manage_tabs_message=Groups+changed."
% self.absolute_url())
- setGroups = postonly(setGroups)
InitializeClass(StateDefinition)
Modified: CMF/branches/2.1/DCWorkflow/WorkflowUIMixin.py
===================================================================
--- CMF/branches/2.1/DCWorkflow/WorkflowUIMixin.py 2007-06-28 15:33:50 UTC (rev 77181)
+++ CMF/branches/2.1/DCWorkflow/WorkflowUIMixin.py 2007-06-28 17:25:27 UTC (rev 77182)
@@ -20,6 +20,7 @@
from Globals import DTMLFile
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
+from AccessControl.requestmethod import postonly
from Acquisition import aq_get
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
@@ -27,7 +28,6 @@
from permissions import ManagePortal
from Guard import Guard
from utils import _dtmldir
-from Products.CMFCore.utils import postonly
try:
#
@@ -54,6 +54,7 @@
manage_groups = PageTemplateFile('workflow_groups.pt', _dtmldir)
security.declareProtected(ManagePortal, 'setProperties')
+ @postonly
def setProperties(self, title, manager_bypass=0, props=None,
REQUEST=None, description=''):
"""Sets basic properties.
@@ -69,7 +70,6 @@
if REQUEST is not None:
return self.manage_properties(
REQUEST, manage_tabs_message='Properties changed.')
- setProperties = postonly(setProperties)
_permissions_form = DTMLFile('workflow_permissions', _dtmldir)
@@ -83,6 +83,7 @@
)
security.declareProtected(ManagePortal, 'addManagedPermission')
+ @postonly
def addManagedPermission(self, p, REQUEST=None):
"""Adds to the list of permissions to manage.
"""
@@ -94,9 +95,9 @@
if REQUEST is not None:
return self.manage_permissions(
REQUEST, manage_tabs_message='Permission added.')
- addManagedPermission = postonly(addManagedPermission)
security.declareProtected(ManagePortal, 'delManagedPermissions')
+ @postonly
def delManagedPermissions(self, ps, REQUEST=None):
"""Removes from the list of permissions to manage.
"""
@@ -108,7 +109,6 @@
if REQUEST is not None:
return self.manage_permissions(
REQUEST, manage_tabs_message='Permission(s) removed.')
- delManagedPermissions = postonly(delManagedPermissions)
security.declareProtected(ManagePortal, 'getPossiblePermissions')
def getPossiblePermissions(self):
@@ -138,6 +138,7 @@
return [g['id'] for g in groups]
security.declareProtected(ManagePortal, 'addGroup')
+ @postonly
def addGroup(self, group, RESPONSE=None, REQUEST=None):
"""Adds a group by name.
"""
@@ -148,9 +149,9 @@
RESPONSE.redirect(
"%s/manage_groups?manage_tabs_message=Added+group."
% self.absolute_url())
- addGroup = postonly(addGroup)
security.declareProtected(ManagePortal, 'delGroups')
+ @postonly
def delGroups(self, groups, RESPONSE=None, REQUEST=None):
"""Removes groups by name.
"""
@@ -159,7 +160,6 @@
RESPONSE.redirect(
"%s/manage_groups?manage_tabs_message=Groups+removed."
% self.absolute_url())
- delGroups = postonly(delGroups)
security.declareProtected(ManagePortal, 'getAvailableRoles')
def getAvailableRoles(self):
@@ -187,6 +187,7 @@
return self.valid_roles()
security.declareProtected(ManagePortal, 'setRoles')
+ @postonly
def setRoles(self, roles, RESPONSE=None, REQUEST=None):
"""Changes the list of roles mapped to groups by this workflow.
"""
@@ -199,7 +200,6 @@
RESPONSE.redirect(
"%s/manage_groups?manage_tabs_message=Roles+changed."
% self.absolute_url())
- setRoles = postonly(setRoles)
security.declareProtected(ManagePortal, 'getGuard')
def getGuard(self):
More information about the CMF-checkins
mailing list