[Zope3-dev] Field constructors
Jim Fulton
jim at zope.com
Tue Jan 13 06:59:50 EST 2004
Philipp von Weitershausen wrote:
>>> 4. It'd be cool if you could use the standard schema field fields
>>> such as title and description instead of __doc__. This way, it'd be
>>> very easy to turn those schemas into web forms for local menus.
>>
>>
>> Sorry, you lost me on this one.
>
>
> 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 find the former more readable. 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. :/
> A field defined like this (not to forget the missing i18n) can be used
> to generated web forms for some UI interface.
Ah, I see you're point. In particular:
title = TextLine(
__doc__ = _(
"""Menu item title
The title provides the basic label for the menu item.
"""),
required=True.
)
is not equivalent to:
title = TextLine(
title=_(u"Menu item title"),
description=_(u"""The title provides the basic label
for the menu item."""),
required=True.
)
because the extraction of the title and description from the doc string
loses the I18n domain. This is easily fixed.
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