Static Resources

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Static Resources

Paul Sephton-2
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
src/module1/__init__.py
src/module1/module1.py
src/module1/module1_templates
src/module1/module1_templates/view-mod1.pt

The main app_macro.pt references static/img1.fav

The submodule view 'view-mod1.pt' references the macro '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



_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Static Resources

Noe Nieto
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 <[hidden email]>
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
src/module1/__init__.py
src/module1/module1.py
src/module1/module1_templates
src/module1/module1_templates/view-mod1.pt

The main app_macro.pt references static/img1.fav

The submodule view 'view-mod1.pt' references the macro '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



_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev




--
---
Noe Nieto
NNieto Consulting Services
M: [hidden email]
W: http://noenieto.com
T:  @tzicatl
Li: Perfil en LinkedIn


_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Static Resources

Jan-Wijbrand Kolman-3
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 <[hidden email] <mailto:[hidden email]>>
>
>     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



_______________________________________________
Grok-dev mailing list
[hidden email]
https://mail.zope.org/mailman/listinfo/grok-dev
Loading...