[Zope3-dev] interface conventions: default=_RAISE_ERROR

Casey Duncan casey@zope.com
Wed, 15 May 2002 14:46:28 -0400


On Wednesday 15 May 2002 02:13 pm, Jim Fulton wrote:
[snip]
> Anybody got any ideas?
>=20
> Maybe the no default case should ommit the verb, as in:
>=20
>   getRequestDefaultViewName(object, request, default=3DNone)
>=20
>   requestDefaultViewName(object, request)
>=20
> Jim

I guess the proble I see is that the word "request" can also be a verb. S=
o are=20
you "requesting" the default view name, or getting it from request?

This also looks very un-object oriented, putting the names of objects/cla=
sses=20
into the names of methods. I would think you would get a "default view=20
finder" adapter on the object and use that. Something like:

viewable =3D getAdapter(IViewable, object)
viewable.getDefaultViewName(request)

then the the other could be maybe:

viewable.defaultViewName(request)

Although the fact that the leading word "get" means "don't thrown an=20
exception" smells funny to me, regardless of the Python convention. Maybe=
=20
instead it should be:

viewable.getDefaultViewName(request, exception=3D1)

Where exception defaults to zero if omitted. I can read this and get some=
=20
understanding that an exception might be generated. Actually the fact tha=
t=20
dict.get return None implicitly defies my intuition. I would expect it to=
=20
raise an exception by default. But, that is just me.

-Casey