[Grok-dev] Static resources usage in different namespace packages

Santiago Videla santiago.videla at gmail.com
Wed Nov 18 06:00:35 EST 2009


I got one solution for my problem. But I am not sure this is the right
> approach:
> >From the second package, I used like this:
>    <link rel="stylesheet" type="text/css"
>           tal:attributes="href python: view.url(context.__parent__,
> '@@/namespace.pkg1/style.css')" />

You may want to use hurry.resource [1] for this. Checkout hurry.jquery [2]
or hurry.extjs [3] to see how to use it.

Basically, you will be able to write, somewhere in namespace.pkg1...let's
say resources.py:

from hurry.resource import Library, ResourceInclusion
resources_pkg1 = Library('static') # 'static' should be the name of a
registered resourceDirectory

styles_pkg1 = ResourceInclusion(resources_pkg1, 'css/style.css')

And then, in namespace.pkg2, in some grok.View or grok.AddForm,
grok.EditForm or whatever you need the resources:

from namespace.pkg1.resources import styles_pkg1

class MyView(grok.View):
     def update(self):

And that's all. Hope it helps.

Best Regards

[1] http://pypi.python.org/pypi/hurry.resource/
[2] http://pypi.python.org/pypi/hurry.jquery/
[3] http://pypi.python.org/pypi/hurry.extjs/

> Regards,
> Baiju M
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev

Santiago Videla

Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el
pensamiento que se hace corazón resplandece con la palabra sencilla y
humilde que l at s tod at s somos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20091118/c94d6372/attachment-0001.html 

More information about the Grok-dev mailing list