[Grok-dev] Using fanstatic on your widgets

Sylvain Viollon sylvain at infrae.com
Thu Nov 24 06:34:12 UTC 2011

Op 24 nov 2011, om 06:15 heeft Noe Nieto het volgende geschreven:


> I was playing with fanstatic in a custom widget for zope.formlib and i'm
> surprised how easy is to need() some javascript resource within some widget.
> Here some snippet:
> import grok
> from zope.formlib.widgets import TextWidget
> from yourapp.resource import library
> from fanstatic import Resource
> myJavascript = Resource(library, 'path/to/code.js')
> class MyCustomWidget(TextWidget):
>    def __call__(self):
>        myJavascript.need()
>        #Some other stuff
>        super(TextWidget, self).__call__()
> Aaand, that should do.

  That's the advantage of Fanstatic.  I had a similar surprise yesterday. I had a table form made with http://pypi.python.org/pypi/zeam.form.table, where I just added an update method and a need for
http://pypi.python.org/pypi/js.jquery_datatables (and a startup script), and I had a kick ass form in two lines
without changing any template.

   I won't say it made my day, but almost.



Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands

More information about the Grok-dev mailing list