Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install zope.fanstatic

How to install zope.fanstatic

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install zope.fanstatic
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.12 Available View build log
0.11 Available View build log
0.10 Available View build log
0.9.1 Available View build log
0.9b Available View build log
Windows (64-bit)
0.12 Available View build log
0.11 Available View build log
0.10 Available View build log
0.9.1 Available View build log
0.9b Available View build log
Mac OS X (10.5+)
0.12 Available View build log
0.11 Available View build log
0.10 Available View build log
0.9.1 Available View build log
0.9b Available View build log
Linux (32-bit)
0.12 Available View build log
0.11 Available View build log
0.10 Available View build log
0.9.1 Available View build log
0.9b Available View build log
Linux (64-bit)
0.12 Available View build log
0.11 Available View build log
0.10 Available View build log
0.9.1 Available View build log
0.9b Available View build log
 
License
ZPL 2.1
Lastest release
version 0.12 on Sep 1st, 2011

Zope integration for fanstatic

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

  • provide access to the needed resources throughout the request/response cycle.
  • provide the base URL for the resources to be rendered.
  • clear the needed resources when an exception view is 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.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>
Exception views

When an exception occurs in the rendering of a view, we don't want to have any needed resources intended for a view being also injected in the error view. The needed resources are cleared and if the exception view chooses to do so, it can need resources itself.

>>> browser.raiseHttpErrors = False
>>> browser.open('http://localhost/zope.fanstatic.test_error')
>>> import fanstatic
>>> fanstatic.get_needed().has_resources()
False

CHANGES

0.12 (2011-08-31)
  • Similar to the fix in 0.11, make sure calling for the URL of a resource will not failed for a DummyNeededResources object which would badly hurt testability of function or "browser" tests of applications that depend on fanstatic/zope.fanstatic.
0.11 (2011-08-17)
  • Fix bug where calling ensure_base_url() failed for DummyNeededResources objects. This was problematic when writing functional or "browser" tests of applications that depend on fanstatic/zope.fanstatic.
0.10 (2011-04-11)
  • Update to fanstatic 0.11 API.
0.9.1 (2011-01-20)
  • Do not clear resources on DummyNeededResources objects.
0.9 (2011-01-20)
  • Integrate zope.errorview, subscribing to the HandleExceptionEvent. This will clear the needed resources thusfar required, to have a clean slate for the error view to be rendered.
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

Subscribe to package updates

Last updated Sep 1st, 2011

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.