[Zope-Coders] RFC: Death to string exceptions
Tres Seaver
tseaver at zope.com
Mon Nov 17 13:34:59 EST 2003
On Mon, 2003-11-17 at 11:47, Paul Winkler wrote:
> On Mon, Nov 17, 2003 at 10:27:48AM -0500, Tres Seaver wrote:
> > Can anyone thing of a good reason not to exterminate the use of string
> > exceptions in the Zope core, both for the 2.7 branch and for the head?
> > For instance, are there known (not hypothetical) products which rely on
> > them deeply? There are several places where we raise "named" strings;
> > clients who already use the names should be safe.
> >
> > Removing them will silence the majority of deprecation warnings which
> > currently pollute the 'make test' output for 2.7.
>
> FYI I grepped my installed Products for string exceptions,
> and only found these:
>
> CMFDefault/Document.py: except 'EditingConflict', msg:
> CMFDynamicDocument1_1_11/DynamicDocument.py: except 'EditingConflict', msg:
That one is internal to the CMF, and should be zapped (but in a separate
geddon :)
> CMFPlone/PloneFolder.py: except (Unauthorized, 'Unauthorized'):
> CMFPlone/StatelessTree.py: except (Unauthorized, 'Unauthorized'):
The string form should be removable, once Plone is no longer trying to
be backward-compatible with Zope < 2.7.
> CMFPlone/skins/plone_form_scripts/content_status_modify.cpy:except 'Unauthorized':
> CMFPlone/skins/plone_form_scripts/content_status_modify.cpy: except 'Unauthorized':
Unless these also have the non-string form, they should be extended to
catch it (zExceptions.Unauthorized); the string form will then be
removable at the same time ast the others (the string form of
Unauthorized has been gone for a while now already).
> CMFPlone/skins/plone_scripts/isExpired.py:except 'TimeError':
This will need to import DateTime.DateTime.TimeError and catch it.
> ormulator/Validator.py: except ('DateTimeError', 'Invalid Date Components', 'TimeError'):
Likewise for DateTime.DateTime.DateTimeError. The middle one was
*never* catchable at all (exceptions are caught by identity, not
equality; Python interns "short" string literals as long as they don't
have white space).
> GroupUserFolder/GroupsTool.py: except 'BadRequest':
Will need to import zExceptions.BadRequest and catch it.
> LocalFS/LocalFS.py: except 'NotFound': pass
> LocalFS/LocalFS.py: except 'NotFound': raise AttributeError, attr
Will need to import zExceptions.NotFound and catch it.
> LocalFS/LocalFS.py: except: raise 'Upload Error', MessageDialog(
> LocalFS/LocalFS.py: except: raise 'Rename Error', MessageDialog(
Should probably raise some product-specific exception.
> LocalFS/LocalFS.py: except 'Forbidden': pass
Will need to import zExceptions.Forbidden and catch it.
> NuxCPS/skins/folder_retitle.py: except 'Unauthorized': # Unauthorized, object must be locked
> NuxWorkgroup/skins/workgroup_retitle.py: except 'Unauthorized': # Unauthorized, object must be
> locked
> mxmRelations/mxmRelations.py: except 'Unauthorized':
>
As with content_status_modify, should be catching
zExceptions.Unauthorized.
>
> Not too bad considering my current product list (a few of these
> are in-house products, most are third-party):
>
> BTreeFolder
> BTreeFolder2
> CaseStudy
> CMFActionIcons
> CMFArticle
> CMFCalendar
> CMFCore
> CMFDecor
> CMFDefault
> CMFDynamicDocument1_1_11
> CMFFormController
> CMFPlone
> CMFQuickInstallerTool
> CMFTopic
> ContentProxy
> CTILdapUser
> CTIPortalData
> DCWorkflow
> DocumentLibrary
> easyArticle
> easyArticleList
> ExternalEditor
> Formulator
> FSCacheManager
> GroupUserFolder
> LDAPUserFolder
> LocalFS
> Localizer
> mxm
> mxmRelations
> NuxCPSDocuments
> NuxCPSMembersPrivateArea
> NuxCPSMessageCatalog
> NuxCPSPreferences
> NuxDocument
> NuxMetaDirectories
> NuxPortal
> NuxWorkgroup
> NuxCPS
> NuxExtendedWorkflow
> NuxHierarchies
> NuxUserGroups
> OrderedFolderSupportPatch
> PortalContentFolder
> RelationAwareFolder
> VersionManager
> WorkflowSchema
> ZSyncer
Thanks very much for chasing that down!
Tres.
--
===============================================================
Tres Seaver tseaver at zope.com
Zope Corporation "Zope Dealers" http://www.zope.com
More information about the Zope-Coders
mailing list