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

Hermann Himmelbauer dusty at qwer.tk
Fri Jul 13 11:49:46 EDT 2007

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.

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"?

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 />

This is boilerplate code I'd rather like to avoid. Moreover, I can register my 
snippets on specific widgets and also on specific modes. In my case, I could 
probably use the same template for input and display widgets as I simply 
register one snippet for input, and another for display.
In case of macros, I assume I'd have to rewrite my template, as I have to use 
e.g.: "metal:use-macro="snippets/foo_input"" 
and "metal:use-macro="snippets/foo_display"".

> That said, you can, like everyone else, put your package into the z3c
> namespace for other people to use. For example ``z3c.widgetsnippet`` would
> work. The code is definitely out of scope for z3c.form and z3c.formui.

Well, that's certainly a possibility. Currently I'm 
implementing "Form-Frames", which complement snippets by adding surrounding 
template code, such as <form>, buttons etc., let's see...

Best Regards,

x1 at aon.at
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7

More information about the Zope3-users mailing list