[Zope3-dev] Re: registering nameless utilities
Jim Fulton
jim at zope.com
Mon May 10 10:07:00 EDT 2004
Garrett Smith wrote:
> Jim Fulton wrote:
>
>> Garrett Smith wrote:
>>
>>> I want to lookup a utility using:
>>>
>>> zapi.getUtility(iface)
>>>
>>> When I try to register a local utility with a site manager, the UI
>>> insists I provide a name. (The 'name' attribute of
>>> IUtilityRegistration is required.)
>>
>>
>>
>> This is undoubtably due to the fact that the schema system, unfotunately,
>> can't tell the differene between an empty string and one that hasn't been
>> provided, even when the minimum string length is 0.
>
>
> Ah yes, this debate :-)
>
> If this truly is a three-state value (!= '', '', and None), we'll need a
> different widget as a text field can only convey two states.
It's just a string that has zeo or more characters.
> When it comes to registering utilities, is there a practical difference
> between '' and None?
Yes. The name is required, but can be ''.
None is not acceptable.
> I would think we could use one or the other to
> indicate a 'nameless' utility.
There aren't really nameless utilities. The default name, when one
isn't specified in a getUtility call is ''.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list