[Zope-CMF] Re: [dev] some questions regarding Exceptions

Yuppie schubbe at web.de
Tue Sep 16 06:59:59 EDT 2003


Hi!


Seb Bacon wrote:
> Yuppie wrote:
>> Something like this?
>>
>>   class CMFError(StandardError):
>>     ...
>>   class MembershipError(CMFError):
>>     ...
>>   class MetadataError(CMFError):
>>     ...
>>   ...
> 
> 
> Definitely.  I can imagine it might be worth discussing the exception 
> hierarchy a bit.

After rereading the python docs, I think the root exception has to be

   class CMFError(Exception):

Thats the easy part.


For the hierarchy I see two possible approaches:

a) by type (CMFValueError, CMFUnauthorizedError, ...)

b) by module/context (MembershipError, MetadataError, ...)

We also could combine these two:

   class MembershipValueError(ValueError, CMFError):
   class MembershipUnauthorizedError(Unauthorized, CMFError):
   class MetadataValueError(ValueError, CMFError):
   class MetadataUnauthorizedError(Unauthorized, CMFError):
   ...


I attached the result of grepping CMF 1.4. Currently both approaches 
exist. The combined solution would provide the best backwards 
compatibility, but I'm afraid that's overkill.

I'd prefer approach b).


Any thoughts?

Cheers,
	Yuppie



---------------------------------------------------------
Exceptions raised in CMF 1.4
(might not be exact, but should be close to that)

Python:
38 x ValueError
11 x KeyError
05 x NotImplementedError
03 x AttributeError
02 x RuntimeError
01 x NameError

Zope:
09 x Unauthorized
01 x ResourceLockedError

CMF:
12 x WorkflowException(Exception)
06 x MetadataError(Exception)
03 x IllegalHTML(ValueError)
02 x SkinPathError(Exception)
02 x DiscussionNotAllowed(Exception)
01 x ObjectMoved(Exception)
01 x ObjectDeleted(Exception)

String:
14 x 'Unauthorized'
10 x 'Bad Request'
06 x 'Not implemented'
05 x 'Syndication is not Allowed'
04 x 'NotFound'
04 x 'Calendar Type Error'
02 x 'ValueError'
02 x 'Syndication is Disabled'
01 x 'This object does not have ...
01 x 'Syndication Information Exists'
01 x 'Redirect'
01 x 'Object does not have ...
01 x 'Not Found'
01 x 'MemberDataError'
01 x 'EditingConflict'
01 x 'Can't add Member'






More information about the Zope-CMF mailing list