[Zope3-Users] Re: Introducing z3c.form - widget snippets

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jul 13 12:42:55 EDT 2007


On Friday 13 July 2007 11:49, Hermann Himmelbauer wrote:
> Am Freitag, 13. Juli 2007 16:08 schrieb Stephan Richter:
> > On Wednesday 11 July 2007 12:14, Hermann Himmelbauer wrote:
> > > Please tell me what you think, if you like it, perhaps it could be
> > > included in z3c.form?
> >
> > I have the same question as Roger.
>
> Hmmm, I missed that one, I think...
>
> > What do these snippets do that cannot be
> > done with macros or viewlets already? When doing custom projects, I
> > expect any developer to develop their own form templates. The
> > ``z3c.formui`` templates are merely examples, which is the reason they
> > are in their own package and layer.
>
> One reason could be that I simply don't understand some aspects of
> z3c.form/macros etc. For me, it was so complicated in my non-generated
> forms that I rather invented something on my own.

All you got to do is create your own full form.pt and register the macros in 
order to have hooks. You can even leave out all the macro registrations.

> Another aspect for me is, that I personally don't like macros so much, with
> these "widget snippets", I hope, I can avoid them in my application. For me
> macros tend to be complex ("unübersichtlich" - I think there's no direct
> translation for that german word?), and I don't see how they would work
> well in the case when I don't use generated forms but arrange the widgets
> manually. Probably I would need an extra macro that acts as my "snippet"?

Yep.

> So, in my snippet-way, it looks like that for every widget:
>
> <span replace="structure view/widgets/mywidget/snippets/foo" />
>
> And in the macro-style? Perhaps like that?
>
> <span metal:use-macro="snippets/foo">
>   <span metal:fill-slot="snippet">
>     <span replace="structure view/widgets/mywidget/render />
>   </span>
> </span

This is overcomplicated. If I remember correctly, you can do:

<tal:block define="widget view/widgets/mywidget">
  <span metal:use-macro="macro:snippet" />
</tal:block>

Also, if you do not like macros, you can register simple views to have:

<span replace="structure view/widgets/mywidget/foo" />

For me the cost of the snippet is too high:

1. It introduces a new pattern for cases that are well-covered otherwise.
2. It requires a new directive.

But as I said before, you should publish your work and see how people like it.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list