[Zope-CMF] [dev] some questions regarding Exceptions
seb bacon
seb at jamkit.com
Fri Sep 12 11:05:36 EDT 2003
Yuppie wrote:
> Hi!
>
>
> Today I did have a closer look at Exception handling in CMF. These are
> my questions:
>
>
> 1.) document_edit.py, metadata_edit.py and newsitem_edit.py in
> CMFDefault are using this pattern:
>
> try:
> context.edit( ...
> context.REQUEST.RESPONSE.redirect( ...
> except Exception, msg:
> context.REQUEST.RESPONSE.redirect( ...
>
> Am I right that these excepts also catch ConflictErrors, what's a Bad
> Thing in general and especially with edit methods?
Yes, definitely. In general it's a Bad Thing to catch all Exceptions
without exception, because the "swallow everything" approach masks
problems in an unhelpful way. However, I guess these scripts are
written as they are precisely so they can catch the string exceptions
you mention.
> 2.) There are still many string exceptions in CMF. All the others are
> not accessible TTW.
>
> What would be the right way to resolve this?
>
> We could use allow_module() and allow_class(). I guess in that case all
> Exceptions should be in one module. Something like CMFCoreExceptions.py?
I like that idea. If we design a core set of exceptions well, then
folks can subclass them for their own needs and they'll still be caught
by generic scripts.
> Or are there some CMF Exceptions that shouldn't be accessible TTW?
I don't see why you shouldn't be able to catch all exceptions TTW.
> Other thoughts?
The big blocker I can see is that achieving backwards compatibility
could be a struggle. I'm not sure about this though, someone would have
to do a brief audit I guess.
Seb
More information about the Zope-CMF
mailing list