I was playing with fanstatic in a custom widget for zope.formlib and i&#39;m surprised how easy is to need() some javascript resource within some widget.<div><br></div><div>Here some snippet:</div><div><br></div><div>import grok</div>

<div>from zope.formlib.widgets import TextWidget</div><div>from yourapp.resource import library</div><div>from fanstatic import Resource</div><div><br></div><div>myJavascript = Resource(library, &#39;path/to/code.js&#39;)</div>

<div><br></div><div>class MyCustomWidget(TextWidget):</div><div>    def __call__(self):</div><div>        myJavascript.need()</div><div>        #Some other stuff</div><div>        super(TextWidget, self).__call__()</div>
<div>
<br></div><div><div><div><br></div><div>Aaand, that should do.</div><div><br></div>-- <br><span style="color:rgb(255, 204, 102)">---</span><br>
<span style="color:rgb(204, 153, 51)">Noe Nieto</span><br>
NNieto Consulting Services<br>
M: <a href="mailto:nnieto@noenieto.com" target="_blank">nnieto@noenieto.com</a><br>
W: <a href="http://noenieto.com" target="_blank">http://noenieto.com</a><br>
T:  <a href="https://twitter.com/#%21/tzicatl" target="_blank">@tzicatl</a><br>Li: <a href="http://www.linkedin.com/profile/view?id=84300665" target="_blank">Perfil en LinkedIn</a><br><br>
</div></div>