Skip to main content

Implementations and means for configuration of Zope 3-style views and resources.

Project description

Overview

This package is at present not reusable without depending on a large chunk of the Zope Toolkit and its assumptions. It is maintained by the Zope Toolkit project.

zope.publisher is a general purpose object publishing framework which delegates to a publication object for determining the to-be-published object. With Zope 3’s default publication from zope.app.publication, this is usually a view or a resource.

This package, zope.app.publisher, provides base implementations for those. It also provides ZCML directives for configuring views and resources. More specifically, zope.app.publisher defines the following ZCML directives:

  • browser:page

  • browser:pages

  • browser:view

  • browser:menu

  • browser:menuItem

  • browser:menuItems

  • browser:addMenuitem

  • browser:resource

  • browser:resourceDirectory

  • browser:defaultSkin

  • browser:icon

  • xmlrpc:view

Views and Browser pages

XXX writeme

Resources

Resources are static files and directories that are served to the browser directly from the filesystem. The most common example are images, CSS style sheets, or JavaScript files.

Resources are be registered under a symbolic name and can later be referred to by that name, so their usage is independent from their physical location.

You can register a single file with the <browser:resource> directive, and a whole directory with the <browser:resourceDirectory> directive, for example

<browser:resource

directory=”/path/to/static.file” name=”myfile” />

<browser:resourceDirectory

directory=”/path/to/images” name=”main-images” />

This causes a named adapter to be registered that adapts the request to zope.interface.Interface (XXX why do we not use an explicit interface?), so to later retrieve a resource, use zope.component.getAdapter(request, name=’myfile’).

There are two ways to traverse to a resource,

  1. with the ‘empty’ view on a site, e. g. http://localhost/@@/myfile (This is declared by zope.app.publisher.browser)

  2. with the ++resource++ namespace, e. g. http://localhost/++resource++myfile (This is declared by zope.traversing.namespace)

In case of resource-directories traversal simply continues through its contents, e. g. http://localhost/@@/main-images/subdir/sample.jpg

Rather than putting together the URL to a resource manually, you should use zope.traversing.browser.interfaces.IAbsoluteURL to get the URL, or for a shorthand, call the resource object. This has an additional benefit:

If you want to serve resources from a different URL, for example because you want to use a web server specialized in serving static files instead of the appserver, you can register an IAbsoluteURL adapter for the site under the name ‘resource’ that will be used to compute the base URLs for resources.

For example, if you register ‘http://static.example.com/’ as the base ‘resource’ URL, the resources from the above example would yield the following absolute URLs: http://static.example.com/myfile and http://static.example.com/main-images (XXX what about http://static.example.com/main-images/subdir/sample.jpg?)

CHANGES

3.8.4 (2009-07-23)

  • Added dependency on zope.app.pagetemplate, it is used by zope.app.publisher.browser.viewmeta.

3.8.3 (2009-06-18)

  • Bugfix: Fix IAbsoluteURL for IResource configuration. The latest release was moving the url generation for resources to an adapter which was a good idea. But the adapter was configured for IDefaultBrowserLayer. This means every existing project which dosen’t use IDefaultBrowserLayer will get a wrong IAbsoluteURL adapter and is loosing the @@ part in the resource url.

3.8.2 (2009-06-16)

  • Remove test dependency on zope.app.pagetemplate.

  • Calling a resource to get its URL now uses IAbsoluteURL.

3.8.1 (2009-05-25)

  • Updated to use zope.pagetemplate.engine module (requires versino 3.5.0 or later), instead of zope.app.pagetemplate precursor.

  • Replaced zope.deprecation dependency with BBB imports

3.8.0 (2009-05-23)

  • There is no direct dependency on zope.app.component anymore (even in the tests).

  • Moved the publicationtraverse module to zope.traversing, removing the zope.app.publisher -> zope.app.publication dependency (which was a cycle).

  • Moved the DefaultViewName API from zope.app.publisher.browser to zope.publisher.defaultview, making it accessible to other packages that need it.

3.7.0 (2009-05-22)

  • Use zope.componentvocabulary instead of zope.app.component (except for tests and IBasicViewInformation).

  • Use zope.browser for IAdding interface (instead of zope.app.container)

  • Update references to zope.app.component.tests.views to point to the new locations in zope.component.testfiles.views.

3.6.2 (2009-03-18)

  • Register IModifiableUserPreferredLanguages adapter in the ZCML configuration of zope.app.publisher.browser package. This was previously done by zope.app.i18n.

3.6.1 (2009-03-12)

  • Remove deprecated code.

  • Adapt to removal of deprecated interfaces from zope.component.interfaces. The IResource is now moved to zope.app.publisher.interfaces. The IView and IDefaultViewName is now in zope.publisher.interfaces. The IPresentation interface was removed completely.

3.6.0 (2009-01-31)

  • Use zope.container instead of zope.app.container.

  • Use zope.site.folder instead of zope.app.folder.

3.5.3 (2009-01-27)

  • Finally removed <browser:skin> and <browser:layer> that were marked as deprecated in 2006/02.

3.5.2 (2008-12-06)

  • Added possibility to specify custom item class in menuItem, subMenuItem and addMenuItem directives using the item_class argument (LP #291865).

  • Menu items registered with <browser:page/> were not re-registered after the first functional test layer ran. In any subsequent functional test layer the items where not availabe (introduced in 3.5.0a3).

  • Added a hook to specify a different BaseURL for resources. This makes sense if you want to put resources on a Content Delivery Network. All you need to do is to register an named Adapter ‘resource’ that implements IAbsoluteURL.

3.5.1 (2008-10-13)

  • Removed usage of deprecated LayerField from zope.app.component.back35.

3.5.0 (2008-08-05)

  • Refactored code to provide more hooks when deriving code from this pacakge.

    • A resource’s URL creation is now in its own method.

    • The resource class of factories can be overwritten.

    • The cache timeout value can now be set as a class or instance attribute.

3.5.0a4 (2007-12-28)

  • Backed out the changes for the controversial XML-RPC skin support.

3.5.0a3 (2007-11-27)

  • make it possible to override menus: this was not possible because new interfaces where created any time a menu with the same name was created.

  • Resolve ZopeSecurityPolicy deprecation warning.

3.5.0a2 (2007-08-23)

  • <browser:defaultView> now accepts classes as well as interfaces.

3.5.0a1 (2007-08-21)

  • Added a layer attribute to xmlrpc:view. This works just like layers for browser:view etc. but uses the IXMLRPCSkinType.

Download files

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

Source Distribution

zope.app.publisher-3.8.4.tar.gz (59.7 kB view hashes)

Uploaded Source

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