[Zope3-dev] Re: Field constructors
Casey Duncan
casey at zope.com
Wed Jan 14 11:19:39 EST 2004
On Wed, 14 Jan 2004 16:53:02 +0100
Philipp von Weitershausen <philipp at weitershausen.de> 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. :)
You took the words right out of my mouth. Part of me likes this idea
another part hates it.
> > I find the former more readable.
Maybe (I'm not sure myself), but it certainly make life harder on the
computer.
> Whatever happened to explicit is better than implicit? People will
> ask: why that magic? (see i18n issue below).
Yeah, this smells kinda bad. I think it's a slippery slope. Pretty soon
we'll be writing full ReST documents in __doc__ and expecting the right
attributes to automagically parse out of it ;^). Seriously though I
think it sets a bad precident, are these really docstrings?
> > I'd actually
> > prefer to be able to write:
> >
> > title = TextLine(
> > """Menu item title
> >
> > The title provides the basic label for the menu item.
> > """,
> > required=True.
> > )
> >
> > This will require a change to the way field constructors are
> > written. :/
>
> 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? It'll make the extractor tool a lot more
>
> complicated as well.
> Maybe I'm overseeing something, but I don't think it'll make our lives
>
> easier, especially when it's just a cosmetic thing.
i18n issues aside, writing triple-quoted strings as args is strange. Are
you going to strip leading whitespace here? What about trailing
newlines? What happens if I forget the blank line after the title?
How about this:
title = TextLine(
"""<doc><title>Menu item title</title>
<description>The title provides the basic
label for the menu item.</description></doc>
""",
required=True.
)
And if you like that I have some swamp land in Florida you might be
interested in too ;^)
-Casey
More information about the Zope3-dev
mailing list