[Zope3-dev] interface conventions: default=_RAISE_ERROR

R. David Murray bitz@bitdance.com
Wed, 15 May 2002 15:05:24 -0400 (EDT)


On Wed, 15 May 2002, Jim Fulton wrote:
> I think we're on the right track looking for method pairs.
[...]
> Maybe the no default case should ommit the verb, as in:
>
>   getRequestDefaultViewName(object, request, default=None)
>
>   requestDefaultViewName(object, request)

How about:

queryRequestDefaultViewName(object, request, default=None)
getRequestDefaultViewName(object, request)

This falls in line with Jim's current-Z2-reality statement that
"get methods spelled with three letters return None if no value
exists, all others raise exceptions" <grin>.

But speaking seriously:

The "evils of getattr" discussion made me think that what
python needs is a way to spell "lookup this variable and use
it's value" (other than exec/eval).  Then, say

  abc.[myvar]

could raise the exception that getattr(abc,myvar) wouldn't.

The basic point, though, is that this amounts to python
having two different "method calls" to get the two different
behaviors (raise exception, return None).  Thus I agree
with Jim, I think we do want paired methods to deal with this
issue.

And since we are trying to be consistent with python,
using 'get' as the prefix probably makes the most sense.

--RDM