[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/utilities - session.py:1.2

Stephan Richter stephan.richter at tufts.edu
Mon Feb 9 06:10:15 EST 2004


On Monday 09 February 2004 00:17, Stuart Bishop wrote:
> +_ = MessageIDFactory("zope")

Sorry for nitpicking, but there is still an easier way:

from zope.app.i18n import ZopeMessageIDFactory as _

> +
> +# XXX: These mapping interfaces should probably live somewhere like
> +# zope.interface.common.mapping, but there are already similar but less
> +# useful ones defined there.

Right, we should definitely think about moving them there and merge these with 
the other version. Why are the others less usefull?

> +_missing = []
> +class IReadMapping(Interface):
> +    ''' Mapping methods for retrieving data '''
> +    def __getitem__(key): 'Return a value'
> +    def __contains__(key): 'True if there is a value for key'
> +    def get(key, default=_missing):
> +        'Return a value, or default if key not found'

I think having missing be a list is a bad idea. If someone appends a value to 
this list, then the default will always have this value. You should use a 
non-mutable type for the default. If not 'None', you can always use 
'object()', which would be the best.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training



More information about the Zope3-Checkins mailing list