[CMF-checkins] CVS: CMF/CMFCore - MemberDataTool.py:1.34
MembershipTool.py:1.47 PortalFolder.py:1.62
SkinsContainer.py:1.11 TypesTool.py:1.69 UndoTool.py:1.18
exceptions.py:1.3 utils.py:1.52
Yvo Schubbe
y.2004_ at wcm-solutions.de
Wed May 5 10:18:55 EDT 2004
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv24494/CMFCore
Modified Files:
MemberDataTool.py MembershipTool.py PortalFolder.py
SkinsContainer.py TypesTool.py UndoTool.py exceptions.py
utils.py
Log Message:
- moved CMFDefault exceptions from CMFCore to CMFDefault
- moved some exceptions to the related exceptions.py
- replaced some string exceptions by zExceptions exceptions
- whitespace cleanup
- import cleanup
=== CMF/CMFCore/MemberDataTool.py 1.33 => 1.34 ===
--- CMF/CMFCore/MemberDataTool.py:1.33 Thu Apr 29 12:13:16 2004
+++ CMF/CMFCore/MemberDataTool.py Wed May 5 10:18:23 2004
@@ -15,23 +15,27 @@
$Id$
"""
-from utils import UniqueObject, getToolByName, _dtmldir
-from OFS.SimpleItem import SimpleItem
-from OFS.PropertyManager import PropertyManager
-from Globals import DTMLFile
-from Globals import InitializeClass
+from AccessControl import ClassSecurityInfo
from AccessControl.Role import RoleManager
+from Acquisition import aq_inner, aq_parent, aq_base
from BTrees.OOBTree import OOBTree
+from Globals import DTMLFile
+from Globals import InitializeClass
+from OFS.PropertyManager import PropertyManager
+from OFS.SimpleItem import SimpleItem
from ZPublisher.Converters import type_converters
-from Acquisition import aq_inner, aq_parent, aq_base
-from AccessControl import ClassSecurityInfo
-from permissions import ViewManagementScreens
+
+from ActionProviderBase import ActionProviderBase
+from exceptions import BadRequest
+from interfaces.portal_memberdata import MemberData as IMemberData
+from interfaces.portal_memberdata import portal_memberdata as IMemberDataTool
from permissions import ManagePortal
from permissions import SetOwnProperties
-from ActionProviderBase import ActionProviderBase
+from permissions import ViewManagementScreens
+from utils import _dtmldir
+from utils import getToolByName
+from utils import UniqueObject
-from interfaces.portal_memberdata import portal_memberdata as IMemberDataTool
-from interfaces.portal_memberdata import MemberData as IMemberData
_marker = [] # Create a new marker object.
@@ -298,10 +302,10 @@
if registration:
failMessage = registration.testPropertiesValidity(properties, member)
if failMessage is not None:
- raise 'Bad Request', failMessage
+ raise BadRequest(failMessage)
member.setMemberProperties(properties)
else:
- raise 'Bad Request', 'Not logged in.'
+ raise BadRequest('Not logged in.')
security.declarePrivate('setMemberProperties')
def setMemberProperties(self, mapping):
=== CMF/CMFCore/MembershipTool.py 1.46 => 1.47 ===
--- CMF/CMFCore/MembershipTool.py:1.46 Thu Apr 29 12:13:16 2004
+++ CMF/CMFCore/MembershipTool.py Wed May 5 10:18:23 2004
@@ -14,22 +14,26 @@
$Id$
"""
+
from types import StringType
-from OFS.Folder import Folder
+from AccessControl import ClassSecurityInfo
+from AccessControl.User import nobody
from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_parent
-from AccessControl.User import nobody
-from AccessControl import ClassSecurityInfo
from Globals import DTMLFile
from Globals import InitializeClass
from Globals import MessageDialog
from Globals import PersistentMapping
+from OFS.Folder import Folder
from ZODB.POSException import ConflictError
from ActionProviderBase import ActionProviderBase
from exceptions import AccessControl_Unauthorized
+from exceptions import BadRequest
+from interfaces.portal_membership \
+ import portal_membership as IMembershipTool
from permissions import AccessContentsInformation
from permissions import ChangeLocalRoles
from permissions import ListPortalMembers
@@ -37,14 +41,11 @@
from permissions import ManageUsers
from permissions import SetOwnPassword
from permissions import View
-from utils import UniqueObject
-from utils import _getAuthenticatedUser
from utils import _checkPermission
-from utils import getToolByName
from utils import _dtmldir
-
-from interfaces.portal_membership \
- import portal_membership as IMembershipTool
+from utils import _getAuthenticatedUser
+from utils import getToolByName
+from utils import UniqueObject
class MembershipTool(UniqueObject, Folder, ActionProviderBase):
@@ -95,10 +96,10 @@
if registration:
failMessage = registration.testPasswordValidity(password)
if failMessage is not None:
- raise 'Bad Request', failMessage
+ raise BadRequest(failMessage)
member.setSecurityProfile(password=password, domains=domains)
else:
- raise 'Bad Request', 'Not logged in.'
+ raise BadRequest('Not logged in.')
security.declarePublic('getAuthenticatedMember')
def getAuthenticatedMember(self):
=== CMF/CMFCore/PortalFolder.py 1.61 => 1.62 ===
--- CMF/CMFCore/PortalFolder.py:1.61 Thu Apr 29 12:13:16 2004
+++ CMF/CMFCore/PortalFolder.py Wed May 5 10:18:23 2004
@@ -15,10 +15,10 @@
$Id$
"""
-import sys
-import re
import base64
import marshal
+import re
+from sys import exc_info
from warnings import warn
from AccessControl import ClassSecurityInfo
@@ -53,6 +53,7 @@
from utils import _checkPermission
from utils import getToolByName
+
factory_type_information = (
{ 'id' : 'Folder'
, 'meta_type' : 'Portal Folder'
@@ -406,8 +407,11 @@
def checkIdAvailable(self, id):
try:
self._checkId(id)
+ except BadRequest:
+ return 0
except:
- if sys.exc_info()[0] == 'Bad Request':
+ # for Zope versions before 2.7.0
+ if exc_info()[0] == 'Bad Request':
return 0
raise # Some other exception.
else:
@@ -434,8 +438,7 @@
# don't allow an override.
# FIXME: needed to allow index_html for join code
if hasattr(ob, id) and id != 'index_html':
- raise 'Bad Request', (
- 'The id "%s" is reserved.' % id)
+ raise BadRequest('The id "%s" is reserved.' % id)
# Otherwise we're ok.
def _verifyObjectPaste(self, object, validate_src=1):
=== CMF/CMFCore/SkinsContainer.py 1.10 => 1.11 ===
--- CMF/CMFCore/SkinsContainer.py:1.10 Thu Apr 29 12:13:16 2004
+++ CMF/CMFCore/SkinsContainer.py Wed May 5 10:18:23 2004
@@ -15,17 +15,13 @@
$Id$
"""
-from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
+from Acquisition import aq_base
from Globals import InitializeClass
-from permissions import AccessContentsInformation
+from exceptions import SkinPathError
from interfaces.portal_skins import SkinsContainer as ISkinsContainer
-
-
-class SkinPathError (Exception):
- 'Invalid skin path'
- pass
+from permissions import AccessContentsInformation
class SkinsContainer:
=== CMF/CMFCore/TypesTool.py 1.68 => 1.69 ===
--- CMF/CMFCore/TypesTool.py:1.68 Thu Apr 29 12:13:16 2004
+++ CMF/CMFCore/TypesTool.py Wed May 5 10:18:23 2004
@@ -15,38 +15,40 @@
$Id$
"""
-import sys
-import warnings
+from sys import exc_info
-from Globals import DTMLFile
-from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager
-from AccessControl import Unauthorized
from Acquisition import aq_base
from Acquisition import aq_get
-from zLOG import LOG, WARNING, ERROR
+from Globals import DTMLFile
+from Globals import InitializeClass
from OFS.Folder import Folder
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from zLOG import LOG, WARNING, ERROR
import Products
+from ActionProviderBase import ActionProviderBase
+from exceptions import AccessControl_Unauthorized
+from exceptions import BadRequest
+from exceptions import zExceptions_Unauthorized
from interfaces.portal_types import ContentTypeInformation as ITypeInformation
from interfaces.portal_types import portal_types as ITypesTool
-
-from ActionProviderBase import ActionProviderBase
from permissions import AccessContentsInformation
from permissions import ManagePortal
from permissions import View
-from utils import UniqueObject
-from utils import SimpleItemWithProperties
-from utils import _dtmldir
from utils import _checkPermission
+from utils import _dtmldir
from utils import _wwwdir
from utils import cookString
from utils import getActionContext
+from utils import SimpleItemWithProperties
+from utils import UniqueObject
+
_marker = [] # Create a new marker.
+
class TypeInformation (SimpleItemWithProperties, ActionProviderBase):
"""
Base class for information about a content type.
@@ -157,7 +159,7 @@
v = v.strip()
if v:
aliases[k] = v
-
+
_dict = {}
for k, v in form['methods'].items():
if aliases.has_key(k):
@@ -393,7 +395,7 @@
_dict = {}
viewmethod = ''
- # order actions and search 'mkdir' action
+ # order actions and search 'mkdir' action
for action in actions:
if action.getId() == 'view':
ordered.insert(0, action)
@@ -474,7 +476,7 @@
product = ''
factory = ''
-
+
#
# Agent methods
#
@@ -489,7 +491,7 @@
self.getId())
if getSecurityManager().validate(p, p, self.factory, m):
return m
- raise Unauthorized, ('Cannot create %s' % self.getId())
+ raise AccessControl_Unauthorized( 'Cannot create %s' % self.getId() )
def _queryFactoryMethod(self, container, default=None):
if not self.product or not self.factory:
@@ -498,7 +500,7 @@
p = container.manage_addProduct[self.product]
except AttributeError:
LOG('Types Tool', ERROR, '_queryFactoryMethod raised an exception',
- error=sys.exc_info())
+ error=exc_info())
return default
m = getattr(p, self.factory, None)
if m:
@@ -507,7 +509,7 @@
# mean unauthorized.
if getSecurityManager().validate(p, p, self.factory, m):
return m
- except Unauthorized:
+ except zExceptions_Unauthorized: # Catch *all* Unauths!
pass
return default
@@ -592,7 +594,7 @@
'container', using 'id' as its id. Return the object.
"""
if not self.isConstructionAllowed(container):
- raise Unauthorized
+ raise AccessControl_Unauthorized
constructor = self.restrictedTraverse( self.constructor_path )
# make sure ownership is explicit before switching the context
@@ -739,11 +741,11 @@
fti = ft
break
if fti is None:
- raise 'Bad Request', ('%s not found.' % typeinfo_name)
+ raise BadRequest('%s not found.' % typeinfo_name)
if not id:
id = fti.get('id', None)
if not id:
- raise 'Bad Request', 'An id is required.'
+ raise BadRequest('An id is required.')
for mt in typeClasses:
if mt['name'] == add_meta_type:
klass = mt['class']
@@ -773,7 +775,7 @@
v = v.strip()
if v:
aliases[k] = v
-
+
for ti in self.listTypeInfo():
_dict = {}
for k, v in form[ ti.getId() ].items():
@@ -808,7 +810,7 @@
def _checkViewType(self,t):
try:
return getSecurityManager().validate(t, t, 'Title', t.Title)
- except Unauthorized:
+ except zExceptions_Unauthorized: # Catch *all* Unauths!
return 0
security.declareProtected(AccessContentsInformation, 'listTypeInfo')
@@ -879,11 +881,11 @@
"""
info = self.getTypeInfo( type_name )
if info is None:
- raise 'ValueError', 'No such content type: %s' % type_name
+ raise ValueError('No such content type: %s' % type_name)
# check we're allowed to access the type object
if not self._checkViewType(info):
- raise Unauthorized,info
+ raise AccessControl_Unauthorized(info)
ob = info.constructInstance(container, id, *args, **kw)
=== CMF/CMFCore/UndoTool.py 1.17 => 1.18 ===
--- CMF/CMFCore/UndoTool.py:1.17 Thu Apr 29 12:13:16 2004
+++ CMF/CMFCore/UndoTool.py Wed May 5 10:18:23 2004
@@ -15,21 +15,22 @@
$Id$
"""
+from AccessControl import ClassSecurityInfo
+from Globals import DTMLFile
+from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
-from Globals import InitializeClass, DTMLFile
-from AccessControl import ClassSecurityInfo, Unauthorized
-from utils import _checkPermission
-from utils import _dtmldir
-from utils import _getAuthenticatedUser
-from utils import UniqueObject
-from Expression import Expression
from ActionInformation import ActionInformation
from ActionProviderBase import ActionProviderBase
+from exceptions import AccessControl_Unauthorized
+from Expression import Expression
+from interfaces.portal_undo import portal_undo as IUndoTool
from permissions import ListUndoableChanges
from permissions import ManagePortal
-
-from interfaces.portal_undo import portal_undo as IUndoTool
+from utils import _checkPermission
+from utils import _dtmldir
+from utils import _getAuthenticatedUser
+from utils import UniqueObject
class UndoTool (UniqueObject, SimpleItem, ActionProviderBase):
@@ -45,7 +46,7 @@
, action=Expression(
text='string:${portal_url}/undo_form')
, condition=Expression(
- text='member')
+ text='member')
, permissions=(ListUndoableChanges,)
, category='global'
, visible=1
@@ -58,7 +59,7 @@
manage_options = ( ActionProviderBase.manage_options +
SimpleItem.manage_options +
({ 'label' : 'Overview', 'action' : 'manage_overview' }
- ,
+ ,
))
#
# ZMI methods
@@ -116,9 +117,8 @@
for tinfo in transaction_info:
if not xids.get( tinfo, None ):
- raise Unauthorized
+ raise AccessControl_Unauthorized
object.manage_undo_transactions(transaction_info)
-
InitializeClass(UndoTool)
=== CMF/CMFCore/exceptions.py 1.2 => 1.3 ===
--- CMF/CMFCore/exceptions.py:1.2 Thu Apr 29 12:13:17 2004
+++ CMF/CMFCore/exceptions.py Wed May 5 10:18:23 2004
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
-""" Declare Exceptions used throughout the CMF.
+""" CMFCore product exceptions.
$Id$
"""
@@ -21,6 +21,22 @@
from webdav.Lockable import ResourceLockedError
from zExceptions import Unauthorized as zExceptions_Unauthorized
+try:
+ from zExceptions import BadRequest
+except ImportError:
+ # for Zope versions before 2.7.0
+
+ class BadRequest(Exception):
+ pass
+
+try:
+ from zExceptions import NotFound
+except ImportError:
+ # for Zope versions before 2.7.0
+
+ class NotFound(Exception):
+ pass
+
security = ModuleSecurityInfo('Products.CMFCore.exceptions')
@@ -28,18 +44,14 @@
# zExceptions_Unauthorized to catch them all.
security.declarePublic('AccessControl_Unauthorized')
+security.declarePublic('BadRequest')
security.declarePublic('CopyError')
+security.declarePublic('NotFound')
security.declarePublic('ResourceLockedError')
security.declarePublic('zExceptions_Unauthorized')
-security.declarePublic('IllegalHTML')
-class IllegalHTML(ValueError):
- """ Illegal HTML error.
- """
-
-
-security.declarePublic('EditingConflict')
-class EditingConflict(Exception):
- """ Editing conflict error.
+security.declarePublic('SkinPathError')
+class SkinPathError(Exception):
+ """ Invalid skin path error.
"""
=== CMF/CMFCore/utils.py 1.51 => 1.52 ===
--- CMF/CMFCore/utils.py:1.51 Thu Apr 29 12:13:17 2004
+++ CMF/CMFCore/utils.py Wed May 5 10:18:23 2004
@@ -48,6 +48,7 @@
from Products.PageTemplates.Expressions import SecureModuleImporter
from exceptions import AccessControl_Unauthorized
+from exceptions import NotFound
security = ModuleSecurityInfo( 'Products.CMFCore.utils' )
@@ -209,7 +210,7 @@
raise AccessControl_Unauthorized( 'No accessible views available for '
'%s' % '/'.join( obj.getPhysicalPath() ) )
else:
- raise 'Not Found', ('Cannot find default view for "%s"' %
+ raise NotFound('Cannot find default view for "%s"' %
'/'.join(obj.getPhysicalPath()))
@@ -466,7 +467,7 @@
obj = tool()
break
if obj is None:
- raise 'NotFound', type
+ raise NotFound(type)
self._setObject(obj.getId(), obj)
if REQUEST is not None:
return self.manage_main(self, REQUEST)
@@ -545,7 +546,7 @@
obj = content_type( id )
break
if obj is None:
- raise 'NotFound', type
+ raise NotFound(type)
self._setObject( id, obj )
if REQUEST is not None:
return self.manage_main(self, REQUEST)
More information about the CMF-checkins
mailing list