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 plone.resource

How to install plone.resource

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install plone.resource
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.0
1.0.2Never BuiltWhy not?
1.0 Available View build log
1.0b6 Available View build log
1.0b5 Available View build log
1.0b4 Available View build log
1.0b3 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
Windows (64-bit)
1.0
1.0.2Never BuiltWhy not?
1.0 Available View build log
1.0b6 Available View build log
1.0b5 Available View build log
1.0b4 Available View build log
1.0b3 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
Mac OS X (10.5+)
1.0
1.0.2Never BuiltWhy not?
1.0 Available View build log
1.0b6 Available View build log
1.0b5 Available View build log
1.0b4 Available View build log
1.0b3 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
Linux (32-bit)
1.0
1.0.2Never BuiltWhy not?
1.0 Available View build log
1.0b6 Available View build log
1.0b5 Available View build log
1.0b4 Available View build log
1.0b3 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
Linux (64-bit)
1.0.2 Available View build log
1.0 Available View build log
1.0b6 Available View build log
1.0b5 Available View build log
1.0b4 Available View build log
1.0b3 Available View build log
1.0b2 Available View build log
1.0b1 Available View build log
 
License
GPL
Lastest release
version 1.0.2 on Jan 9th, 2014

Introduction

plone.resource publishes directories of static files via the ZPublisher. These directories may be located either in the ZODB (as OFS folders and files), or on the filesystem.

Each resource directory has a type and a name. When combined, these are used to traverse to the resource directory. For example:

/++theme++mytheme/<subpath>
/++sitelayout++mylayout/<subpath>
/++templatelayout++mylayout<subpath>
Where resources can be stored

Resource directory contents can be found by the traverser in several different places. The following locations are tried in order.

Files in the ZODB

Installing plone.resource creates a folder called portal_resources which can be used to store resource directories persistently. By convention, the top-level folders under this folder correspond to resource types, and the second-level folders correspond to the resource directory name.

So, the file traversable at /++theme++mytheme/myfile could be physically located at some_site/++etc++site/resources/theme/mytheme

(XXX: provide a helper to upload a tarball/zip)

Files in Python distributions

A folder in a Python distribution (e.g. egg) can be registered as a resource directory of a particular type and name using the plone:static ZCML directive. For example, this registers a directory named "theme" as a resource directory of type "theme". It would be accessible at ++theme++mytheme:

<plone:static
  directory="theme"
  type="theme"
  name="mytheme"
  />

Note

You must do <include package="plone.resource" file="meta.zcml"/> before you can use the plone:static directive.

The name of the resource directory defaults to the name of the package, so can be omitted. e.g. the following directive in a package named "mytheme" would result in the same registration as above:

<plone:static
  directory="resources"
  type="theme"
  />

Traversing upward in directory paths using .. is not supported, as it could allow unwanted file access.

Minimum zcml config example

Note:

<configure xmlns:plone="http://namespaces.plone.org/plone">
<include package="plone.resource" file="meta.zcml"/>
<plone:static
  directory="resources"
  type="theme"
  name="myproject"
  />
</configure>
Files in a central resource directory

If the plone:static directive is used from site.zcml (i.e., with no active package in the ZCML import context), then it may specify the absolute path to a top-level resources directory. This directory should have the same sub-directory structure as the in-ZODB resources directory in that top-level directories are resource types, and 2nd-level directories are resource directory names. In addition, in order for resources to be available, the top-level directories require a traverser to be registered.

For example, the following in site.zcml would register the given path within the buildout root:

<plone:static
  directory="/path/to/buildout/var/resources"
  />

Typically, this can be injected into site.zcml by specifying the resources option in the plone.recipe.zope2instance buildout recipe, like this:

resources = ${buildout:directory}/resources

As a worked example, if one wanted to serve resources for use with plone.app.theming, which provides the ++theme++ traverser, then a resource located at:

${directory}/resources/theme/my.project/logo.png

would be traversable at a URL like so:

http://localhost:8080/Plone/++theme++my.project/logo.png
Additional traversers

Traversers can be registered via ZCML using an adapter like so:

<adapter
  name="demo"
  for="* zope.publisher.interfaces.IRequest"
  provides="zope.traversing.interfaces.ITraversable"
  factory="my.project.traversal.MyTraverser"
  />

with a corresponding factory definition of:

from plone.resource.traversal import ResourceTraverser
class MyTraverser(ResourceTraverser):
    name = 'demo'

This, when coupled with configuration like that in the Files in a central resource directory section above, would mean that resources located at:

${directory}/resources/demo/my.project/logo.png

would be traversable at a URL like so:

http://localhost:8080/Plone/++demo++my.project/logo.png
What types of resources can be stored

Changelog

1.0.2 (2013-01-01)
  • Nothing changed yet.
1.0.1 (2012-05-25)
1.0 (2012-04-15)
  • Add __setitem__() support for writeable resource directories. [optilude]
1.0b6 (2011-11-24)
  • Added rename() method for writable resource directories [optilude]
  • Added cloneResourceDirectory() helper method in the utils module [optilude]
  • Add a ++unique++ resource traverser for resource directories to cache as 'plone.stableResource'. [elro]
1.0b5 (2011-06-08)
  • Ensure any files are skipped in iterDirectoriesOfType. [elro]
1.0b4 (2011-05-29)
  • Add queryResourceDirectory() helper method. [optilude]
1.0b3 (2011-05-23)
  • Fix resource directory download bug with subdirectories. [elro]
1.0b2 (2011-05-16)
  • Add a more compatible filestream iterator for filesystem files that allows coercion to string or unicode. This fixes possible compatibility issues with resource merging through Resource Registries. [optilude]
1.0b1 (2011-04-22)
  • Initial release

Subscribe to package updates

Last updated Jan 9th, 2014

Download Stats

Last month:1

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.