[CMF-checkins] CVS: CMF/CMFCore - CMFCoreExceptions.py:1.5
MembershipTool.py:1.43 PortalContent.py:1.45 PortalFolder.py:1.53
Yvo Schubbe
schubbe at web.de
Wed Jan 7 11:32:17 EST 2004
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv21212/CMFCore
Modified Files:
CMFCoreExceptions.py MembershipTool.py PortalContent.py
PortalFolder.py
Log Message:
- removed CMF* exception classes
- added some aliases for Zope exceptions to make them usable TTW
- replaced EditingConflict string by class exception
=== CMF/CMFCore/CMFCoreExceptions.py 1.4 => 1.5 ===
--- CMF/CMFCore/CMFCoreExceptions.py:1.4 Sun Jan 4 11:57:00 2004
+++ CMF/CMFCore/CMFCoreExceptions.py Wed Jan 7 11:31:46 2004
@@ -16,41 +16,30 @@
"""
from AccessControl import ModuleSecurityInfo
-from AccessControl import Unauthorized
+from AccessControl import Unauthorized as AccessControl_Unauthorized
from OFS.CopySupport import CopyError
from webdav.Lockable import ResourceLockedError
+from zExceptions import Unauthorized as zExceptions_Unauthorized
security = ModuleSecurityInfo('Products.CMFCore.CMFCoreExceptions')
-security.declarePublic('CopyError')
-security.declarePublic('Unauthorized')
-
-
-security.declarePublic('CMFError')
-class CMFError(Exception):
- """ The root of all CMF evil.
- """
-
-
-security.declarePublic('CMFNotImplementedError')
-class CMFNotImplementedError(NotImplementedError, CMFError):
- """ NotImplementedError in CMF.
- """
+# Use AccessControl_Unauthorized to raise Unauthorized errors and
+# zExceptions_Unauthorized to catch them all.
-security.declarePublic('CMFResourceLockedError')
-class CMFResourceLockedError(ResourceLockedError, CMFError):
- """ ResourceLockedError in CMF.
- """
+security.declarePublic('AccessControl_Unauthorized')
+security.declarePublic('CopyError')
+security.declarePublic('ResourceLockedError')
+security.declarePublic('zExceptions_Unauthorized')
-security.declarePublic('CMFUnauthorizedError')
-class CMFUnauthorizedError(Unauthorized, CMFError):
- """ Unauthorized error in CMF.
+security.declarePublic('IllegalHTML')
+class IllegalHTML(ValueError):
+ """ Illegal HTML error.
"""
-security.declarePublic('IllegalHTML')
-class IllegalHTML(ValueError, CMFError):
- """ Illegal HTML error.
+security.declarePublic('EditingConflict')
+class EditingConflict(Exception):
+ """ Editing conflict error.
"""
=== CMF/CMFCore/MembershipTool.py 1.42 => 1.43 ===
--- CMF/CMFCore/MembershipTool.py:1.42 Mon Oct 20 05:39:59 2003
+++ CMF/CMFCore/MembershipTool.py Wed Jan 7 11:31:46 2004
@@ -30,8 +30,7 @@
from Globals import PersistentMapping
from ActionProviderBase import ActionProviderBase
-from CMFCoreExceptions import CMFNotImplementedError
-from CMFCoreExceptions import CMFUnauthorizedError
+from CMFCoreExceptions import AccessControl_Unauthorized
from CMFCorePermissions import AccessContentsInformation
from CMFCorePermissions import ChangeLocalRoles
from CMFCorePermissions import ListPortalMembers
@@ -123,7 +122,7 @@
u = u.__of__(self.acl_users)
if (b is nobody and not wrap_anon) or hasattr(b, 'getMemberId'):
# This user is either not recognized by acl_users or it is
- # already registered with something that implements the
+ # already registered with something that implements the
# member data tool at least partially.
return u
@@ -158,7 +157,7 @@
def getPortalRoles(self):
"""
Return all local roles defined by the portal itself,
- which means roles that are useful and understood
+ which means roles that are useful and understood
by the portal object
"""
parent = self.aq_inner.aq_parent
@@ -173,7 +172,7 @@
security.declareProtected(ManagePortal, 'setRoleMapping')
def setRoleMapping(self, portal_role, userfolder_role):
"""
- set the mapping of roles between roles understood by
+ set the mapping of roles between roles understood by
the portal and roles coming from outside user sources
"""
if not hasattr(self, 'role_map'): self.role_map = PersistentMapping()
@@ -212,7 +211,7 @@
"""
Returns the flag indicating whether the membership tool
will create a member area if an authenticated user from
- an underlying user folder logs in first without going
+ an underlying user folder logs in first without going
through the join process
"""
return self.memberareaCreationFlag
@@ -262,7 +261,7 @@
if member:
member = member.__of__(self.acl_users)
else:
- raise ValueError, 'Member %s does not exist' % member_id
+ raise ValueError('Member %s does not exist' % member_id)
else:
return None
if hasattr( aq_base(members), member_id ):
@@ -479,10 +478,10 @@
try:
acl_users.userFolderDelUsers(member_ids)
except (NotImplementedError, 'NotImplemented'):
- raise CMFNotImplementedError('The underlying User Folder '
+ raise NotImplementedError('The underlying User Folder '
'doesn\'t support deleting members.')
else:
- raise CMFUnauthorizedError('You need the \'Manage users\' '
+ raise AccessControl_Unauthorized('You need the \'Manage users\' '
'permission for the underlying User Folder.')
# Delete member data in portal_memberdata.
=== CMF/CMFCore/PortalContent.py 1.44 => 1.45 ===
--- CMF/CMFCore/PortalContent.py:1.44 Thu Sep 25 07:36:48 2003
+++ CMF/CMFCore/PortalContent.py Wed Jan 7 11:31:46 2004
@@ -25,14 +25,13 @@
from DynamicType import DynamicType
from utils import _getViewFor
from CMFCatalogAware import CMFCatalogAware
-from CMFCoreExceptions import CMFResourceLockedError
+from CMFCoreExceptions import ResourceLockedError
from CMFCorePermissions import FTPAccess
from CMFCorePermissions import View
# Old names that some third-party packages may need.
NoWL = 0
-from webdav.Lockable import ResourceLockedError
class PortalContent(DynamicType, CMFCatalogAware, SimpleItem):
@@ -81,8 +80,7 @@
Check if isLocked via webDav
"""
if self.wl_isLocked():
- raise CMFResourceLockedError('This resource is locked via '
- 'webDAV.')
+ raise ResourceLockedError('This resource is locked via webDAV.')
return 0
#
=== CMF/CMFCore/PortalFolder.py 1.52 => 1.53 ===
--- CMF/CMFCore/PortalFolder.py:1.52 Tue Dec 23 16:47:23 2003
+++ CMF/CMFCore/PortalFolder.py Wed Jan 7 11:31:46 2004
@@ -18,14 +18,17 @@
import sys
import re, base64, marshal
+from AccessControl import ClassSecurityInfo
+from AccessControl import getSecurityManager
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.Folder import Folder
from OFS.ObjectManager import REPLACEABLE
-from AccessControl import getSecurityManager, ClassSecurityInfo, Unauthorized
from Acquisition import aq_parent, aq_inner, aq_base
from CMFCatalogAware import CMFCatalogAware
+from CMFCoreExceptions import AccessControl_Unauthorized
+from CMFCoreExceptions import zExceptions_Unauthorized
from CMFCorePermissions import AddPortalContent
from CMFCorePermissions import AddPortalFolders
from CMFCorePermissions import ChangeLocalRoles
@@ -34,7 +37,8 @@
from CMFCorePermissions import ManageProperties
from CMFCorePermissions import View
from DynamicType import DynamicType
-from utils import getToolByName, _checkPermission
+from utils import _checkPermission
+from utils import getToolByName
factory_type_information = (
{ 'id' : 'Folder'
@@ -160,8 +164,7 @@
spec = [spec]
for meta_type in spec:
if not meta_type in types:
- raise ValueError, ('%s is not a content type'
- % meta_type )
+ raise ValueError('%s is not a content type' % meta_type)
new_spec.append(meta_type)
return new_spec or types
@@ -243,7 +246,7 @@
try:
if getSecurityManager().validate(self, self, id, v):
l.append(obj)
- except Unauthorized:
+ except zExceptions_Unauthorized: # Catch *all* Unauths!
pass
return l
@@ -354,7 +357,7 @@
if myType is not None:
if not myType.allowType( type_name ):
- raise ValueError, 'Disallowed subobject type: %s' % type_name
+ raise ValueError('Disallowed subobject type: %s' % type_name)
pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
@@ -422,9 +425,9 @@
None, object):
# validation succeeded
return
- raise 'Unauthorized', object.getId()
+ raise AccessControl_Unauthorized( object.getId() )
else:
- raise 'Unauthorized', permission_name
+ raise AccessControl_Unauthorized(permission_name)
#
# Old validation for objects that may not have registered
# themselves in the proper fashion.
@@ -446,10 +449,9 @@
if getSecurityManager().validate(None, parent,
None, object):
return
- id = object.getId()
- raise 'Unauthorized', id
+ raise AccessControl_Unauthorized( object.getId() )
else:
- raise 'Unauthorized', method_name
+ raise AccessControl_Unauthorized(method_name)
PortalFolder.inheritedAttribute(
'_verifyObjectPaste')(self, object, validate_src)
More information about the CMF-checkins
mailing list