Skip to main content

Fanstatic integration for Zope.

Project description

Zope integration for fanstatic

This package provides Zope integration for fanstatic. This means it’s taking care of two things:

  • provide access to the needed resources throughout the request/response cycle.

  • provide the base URL for the resources to be rendered.

This library fulfills these conditions for a Zope Toolkit/Grok setup.

We’ll run through a few tests to demonstrate it. Note that the real code being tested is not in this document itself, but in the views described in ftesting.zcml.

We need to be in a request to make this work, so let’s up a request to a page we have set up in ftesting.zcml that should cause the inclusion of a single resource in its header:

>>> from zope.app.wsgi.testlayer import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/zope.fanstatic.test_single')
>>> print browser.contents
<html>
<head>
<script type="text/javascript" src="http://localhost/fanstatic/foo/a.js"></script>
<BLANKLINE>
</head>
<body>
<p>the widget HTML itself</p>
</body>
</html>

If a resource happens to need another resource, this resource is also automatically included:

>>> browser.open('http://localhost/zope.fanstatic.test_multiple')
>>> print browser.contents
<html>
<head>
  <script type="text/javascript" src="http://localhost/fanstatic/foo/a.js"></script>
  <script type="text/javascript" src="http://localhost/fanstatic/foo/b.js"></script>
<BLANKLINE>
</head>
<body>
<p>the widget HTML itself</p>
</body>
</html>

Let’s force all javascript resources to be forced to be included at the bottom now, just before the </body> tag:

>>> browser.open('http://localhost/zope.fanstatic.test_bottom')
>>> print browser.contents
<html>
<head>
</head>
<body>
<p>the widget HTML itself</p>
<script type="text/javascript" src="http://localhost/fanstatic/foo/a.js"></script>
<script type="text/javascript" src="http://localhost/fanstatic/foo/b.js"></script></body>
</html>

In-template resources

zope.fanstatic provides support for rendering resource publisher aware URLs to in-template resources:

>>> browser.open('http://localhost/zope.fanstatic.test_inline_resource')
>>> print browser.contents
<html>
<head>
</head>
<body>
  <img src="http://localhost/fanstatic/foo/evencaveman.jpg" />
  <img src="http://localhost/fanstatic/foo/sub/evencaveman.jpg" />
</body>
</html>

CHANGES

0.9b (2011-01-06)

Zope.fanstatic version 0.9 is a fundamental rewrite of hurry.zoperesource, as a result of the rewrite of hurry.resource into fanstatic.

Here’s a list of essential changes since version 0.7 of hurry.zoperesource:

  • Compliance with the Fanstatic API.

  • ++resource++foo/bar/baz.jpg expressions in Page Templates are still supported by way registering a traversable component for all available resource libraries. There are no zope.browserresource components involved anymore in zope.fanstatic.

Download

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zope.fanstatic-0.9b.tar.gz (25.8 kB view details)

Uploaded Source

File details

Details for the file zope.fanstatic-0.9b.tar.gz.

File metadata

File hashes

Hashes for zope.fanstatic-0.9b.tar.gz
Algorithm Hash digest
SHA256 c5505d9e6b89f70ce5ecc0a8afa494a6e7e3537ed4ec8d4383954a737b3efd16
MD5 55593afe50c04a0f5be7b5056afc78f6
BLAKE2b-256 023bef7171c2ed3d0bbc88a77c95ab73aa901a81d74a75d557724b1c9a48f895

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page