[Grok-dev] automatic static resources

Noe Nieto nnieto at noenieto.com
Tue Jul 17 15:24:18 UTC 2012


Newer versions of Grok now use fanstatic for delivering static assets.

Make sure you have something like this in your setup.py

setup(name='yourapp',
      version=version,
      description="",
      long_description="Your app",
      # Get strings from
http://www.python.org/pypi?%3Aaction=list_classifiers
      classifiers=[],
      keywords="",
      author="Someone",
      author_email="dude at somewhere.com",
      url="http://www.somewhere.com",
      license="",
      package_dir={'': 'src'},
      packages=find_packages('src'),
      include_package_data=True,
      zip_safe=False,
      install_requires=[
          'setuptools',
          'grok',
          'grokui.admin',
          'fanstatic',
          'zope.fanstatic',
          'grokcore.startup',
          'zope.sendmail',
      ],
      entry_points={
          'fanstatic.libraries': [
              'your_app = your_app.resource:library',
          ]
      },
      )

The entry_points thing is very important. To know why look here:
http://www.fanstatic.org/en/latest/library.html#making-fanstatic-available-in-your-project

Also, fanstatic filter must be declared in your paster.ini file (might be
in etc/debug.ini.in).

[DEFAULT]
zope_conf = %(here)s/zope.debug.conf

[server:main]
use = egg:Paste#http
host = 8000

[pipeline:main]
pipeline = accesslogging evalexception fanstatic grok

[filter:accesslogging]
use = egg:Paste#translogger

[filter:evalexception]
use = egg:z3c.evalexception#ajax

[filter:fanstatic]
use = egg:fanstatic#fanstatic
versioning = false
recompute_hashes = true
debug = true

[app:grok]
use = egg:grokcore.startup#debug


HTH

--
Noe

2012/7/17 Christian Schmidt <grok-list at creativenet.de>

> **
> Hello Group,
>
> today I ran into problems with static while i followed the tutorial:
>
>
> http://grok.zope.org/doc/current/tutorial.html#static-resources-for-our-web-page
>
> I created a static directory, added a styles.css to this directory.
> Finally I worte
>
> <link rel="stylesheet" type="text/css" tal:attributes="href
> static/styles.css">
>
> to my template. Result:
>
> *Line 3, Column 8*
> *In expression: <PathExpr standard:u'static/styles.css'>*
> - Names:
> {'args': (),
> 'context': <dnszones.app.Dnszones object at 0x808eaab90>,
> 'default': <object object at 0x800ec4490>,
> 'loop': {},
> 'nothing': None,
> 'options': {},
> 'repeat': {},
> 'request': <zope.publisher.browser.BrowserRequest instance URL=
> http://127.0.0.1:8080/dnszones/zone>,
> 'static': None,
> 'template': <grokcore.view.components.TrustedFilePageTemplate object at
> 0x8087245d0>,
> 'view': <dnszones.app.DnsZonesZone object at 0x809563350>}
> *
> - > LocationError: (None, 'styles.css')*
>
> Seems that static Directory is not known. Grok book and tutorial
> references that this is done automaticly. Is there a method where i can
> declare where the static resouces can be found - like grok.static('static')
> in my view or viewlet?
>
> How to make static resources availabe direct form view or viewlet template
> without using fanstatic?
>
> -
> Chris
>
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>
>


-- 
---
Noe Nieto
NNieto Consulting Services
M: nnieto at noenieto.com
W: http://noenieto.com
T:  @tzicatl <https://twitter.com/#%21/tzicatl>
Li: Perfil en LinkedIn <http://www.linkedin.com/profile/view?id=84300665>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20120717/462d7681/attachment.html>


More information about the Grok-dev mailing list