[Grok-dev] Static Resources

Jan-Wijbrand Kolman janwijbrand at gmail.com
Mon Sep 19 02:16:49 EST 2011


Paul, has Noe's answer been of help to you? Did you get your issue resolved?

regards, jw

On 7/19/11 17:18 , Noe Nieto wrote:
> New versions of grok come bundled with fanstatic:
>
> http://www.fanstatic.org/en/0.11.2/index.html
> http://grok.zope.org/doc/community/view_generation/fanstatic_resources.html
>
> With fanstatic you'll declare some resource as "needed" in the update()
> method of your python code.
>
> in resource.py:
>
> favicon = Resource(library, 'favicon.ico')
>
> from myapp import resource
>
> class MyView (grok.view):
>      def update():
>          ...
>          resource.favicon.need()
>
> Otherwise, If you still want to do it on the templates, your code should
> look like this:
>
> <link rel="shortcut icon"
>   href="static/favicon.ico"
>    tal:attributes="href static/favicon.ico"/>
>
>
> --
> Noe
>
> 2011/7/18 Paul Sephton <prsephton at gmail.com <mailto:prsephton at gmail.com>>
>
>     Hi;
>
>     I'm a bit stuck, and was hoping someone could help.
>
>     I have a product directory something like the following:
>
>     src/app.py
>     src/resource.py
>     src/static
>     src/static/img1.fav
>     src/app_templates
>     src/app_templates/app_macro.pt <http://app_macro.pt>
>     src/module1/__init__.py
>     src/module1/module1.py
>     src/module1/module1_templates
>     src/module1/module1_templates/view-mod1.pt <http://view-mod1.pt>
>
>     The main app_macro.pt <http://app_macro.pt> references static/img1.fav
>
>     The submodule view 'view-mod1.pt <http://view-mod1.pt>' references
>     the macro 'app-macro.pt <http://app-macro.pt>'
>
>     Now, I'm doing something wrong, but grok can't seem to find img1.fav
>     when the macro is expanded (it finds the macro itself just fine).
>     How do I get around this without duplicating static resources in the
>     submodule directory tree?  In other words, how can a submodule share
>     static resources from the parent directory?
>
>     I would be very grateful for any help!
>
>     Regards,
>     Paul





More information about the Grok-dev mailing list