[Zope3-dev] Re: Field constructors

Jim Fulton jim at zope.com
Wed Jan 14 14:11:06 EST 2004


Philipp von Weitershausen wrote:
> Jim Fulton wrote:
> 
>>  > Ah, well, it's not a big deal really. It's just that you write::
>>  >
>>  >            title = TextLine(
>>  >                __doc__ =
>>  >                """Menu item title
>>  >
>>  >                The title provides the basic label for the menu item.
>>  >                """,
>>  >                required=True.
>>  >                )
>>  >
>>  > while I would prefer the schema convention::
>>  >
>>  >            title = TextLine(
>>  >                title=u"Menu item title",
>>  >                description=u"""The title provides the basic label
>>  >                for the menu item.""",
>>  >                required=True.
>>  >                )
>>
>> They are equivalent.
> 
> 
> I see the majyck in Field.__init__ now. I'm repelled and attracted at 
> the same time. :)
> 
>> I find the former more readable.
> 
> 
> Whatever happened to explicit is better than implicit? People will ask: 
> why that magic? (see i18n issue below).

The Python standard for doc strings specifies that a multi-line
doc string should begin with a summary (ie title) followed by a
description:

   http://www.python.org/peps/pep-0257.html

(Unfortunately, some Zope 3 developers are unaware of this, forcing
  me to rewrite many doc strings.)

Given this, it is quite natural to automatically extract a title
and descriotion from a doc string.


> I'm ok with that. The i18n issue remains, though. And I wouldn't want to 
> sell a newbie that the Field constructor automatically splits the 
> __doc__ and makes message ids out of the title and description. What 
> domain will it make them for?

The same domain as the doc string, but:

 > It'll make the extractor tool a lot more
> complicated as well.

Good point.  I'm convinced.  That't too bad, because I find
the doc string versions to be far more readable (and writable,
for that matter). Dang. :(

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