[Zope3-dev] interface conventions: default=_RAISE_ERROR

Gary Poster garyposter@earthlink.net
Tue, 14 May 2002 15:49:06 -0400


On Tuesday 14 May 2002 03:08 pm, Guido van Rossum wrote:
> > [Jim]
> > Maybe we should switch to having two versions of each get method.
> > This would be easier to implement and to document.  Anybody got
> > a suggestion for a naming convention?
>
> The one that raises an exception should be called __getitem__ and
> normally invoked with obj[key] notation.

Unless I misunderstand, an example of a method for which we need a convention 
is this:

def getRequestView(wrapped_object, name, request, 
default=ComponentLookupError):

That's using the rejected error default convention, so what we need now is a 
naming convention to differentiate pairs of methods (and functions) with 
signatures something like

getRequestView(wrapped_object, name, request, default=None)

vs 

getRequestView(wrapped_object, name, request)

There are many places where we will need method/function pairs to follow this 
convention, and many of them, like this example, do not closely parallel the 
get vs __getitem__ signature.

I don't have a good answer, but I thought I would clarify the problem.

Gary