[Zope3-Users] Re: z3c.form - field description -> widget hint?

Fernando Correa Neto fcdoth at gmail.com
Sun Mar 23 23:07:50 EDT 2008


Hey

On Fri, Jul 13, 2007 at 11:21 AM, Stephan Richter
<srichter at cosmos.phy.tufts.edu> wrote:
[snip]


>  Actually the opposite. I purposefully decided not to map the field's
>  description to anything, because I found it to be useless. If someone really
>  cares to map the field's description to something, I suggest writing a
>  traversal adapter that returns this info; something like this:
>
>  widgets/name/@@hint
>
>  <div class="hint">
>     field description
>  </div>

Mmm....How this traversal adapter would look like? I mean, to solve my
problem I wrote a view for z3c.form.interfaces.IWidget to get the
description as following:

from zope.publisher.browser import BrowserPage

class Hint(BrowserPage):
    """A view that returns the hint from the field"""

    def __init__(self, context, request):
        self.context = context
        self.request = request

    def __call__(self):
        return self.context.field.description

This way I can simply use widget/@@hint and it works.
Am I abusing here? I am interested on how it would be accomplished
with a traversal adapter.

Best Regards,
Fernando


More information about the Zope3-users mailing list