Skip to main content

hurry.resource integration for Zope.

Project description

Zope integration for hurry.resource

This package provides Zope integration for hurry.resource. This means three taking care of three things:

  • maintain the needed resources throughout the request/response cycle.

  • know how to make a URL to a resource.

  • make so that resource references are automatically inserted in the HTML header.

This library fulfills these conditions for a Zope 3/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.testbrowser.testing import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
>>> browser.open('http://localhost/hurry.zoperesource.test_single')
>>> print browser.contents
<html>
<head>
    <script type="text/javascript" src="http://localhost/@@/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/hurry.zoperesource.test_multiple')
>>> print browser.contents
<html>
<head>
    <script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
  <script type="text/javascript" src="http://localhost/@@/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/hurry.zoperesource.test_bottom')
>>> print browser.contents
<html>
<head>
</head>
<body>
<p>the widget HTML itself</p>
<script type="text/javascript" src="http://localhost/@@/foo/a.js"></script>
<script type="text/javascript" src="http://localhost/@@/foo/b.js"></script></body>
</html>

CHANGES

0.4 (2009-12-16)

  • Updated required packages.

  • Use a newer version of hurry.resource which can insert the snippets into HTML itself.

0.3 (2008-12-05)

  • resource.need() needed a request object set up in order to function. This is rather annoying in tests, which often don’t have a request object set up. We now instead return a dummy NeededResources object in such cases (which will then be thrown away). As a result, it’s always safe to call resource.need() during tests, though if no request can be found it will have no effect.

0.2 (2008-10-13)

  • Add support for rendering fragments at the bottom of the page. When you call hurry.resource.bottom resources which are marked bottom-safe will be rendered at the bottom of the web page instead of in the <head> section. When you call hurry.resource.bottom(force=True), all .js resources will be included at the bottom.

0.1 (2008-10-11)

  • Initial public release.

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

hurry.zoperesource-0.4.tar.gz (6.8 kB view details)

Uploaded Source

File details

Details for the file hurry.zoperesource-0.4.tar.gz.

File metadata

File hashes

Hashes for hurry.zoperesource-0.4.tar.gz
Algorithm Hash digest
SHA256 cc2cf45f1a91bbbeb4a4c11179cc399d16d76ffbc368e4d6bc02c247617f8321
MD5 856e02fe7f9c84fe971b89a6bf8d544d
BLAKE2b-256 8db7250b9cf75bc5e4ada9d958e67ddf09de6655d5097b9b100f38c38a7eba44

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