Package configuration

The zope.publisher package provides a ZCML file that configures some adapters and security:

>>> from zope.configuration.xmlconfig import XMLConfig
>>> import zope.publisher
>>> XMLConfig('configure.zcml', zope.publisher)()

The exact count of registered utilities will vary depending on which packages are installed because of the use of zcml:condition="installed ..." clauses in the ZCML.

>>> try:
...    import zope.annotation
... except ImportError:
...   expected_count = 22
... else:
...   expected_count = 23
>>> len(list(zope.component.getGlobalSiteManager().registeredUtilities())) == expected_count
True
>>> len(list(zope.component.getGlobalSiteManager().registeredAdapters()))
11

ZCML Directives

This package also defines some ZCML directives for defining the default skin (browser:defaultSkin) and default view (browser:defaultView).

Default view and default skin ZCML configuration feature.

interface zope.publisher.zcml.IDefaultSkinDirective[source]

Sets the default browser skin

name

Default skin name

Default skin name

Implementation:zope.schema.TextLine
Read Only:False
Required:True
Default Value:None
Allowed Type:unicode
interface zope.publisher.zcml.IDefaultViewDirective[source]

The name of the view that should be the default.

This name refers to view that should be the view used by default (if no view name is supplied explicitly).

name

The name of the view that should be the default.

This name refers to view that should be the view used by default (if no view name is supplied explicitly).

Implementation:zope.schema.TextLine
Read Only:False
Required:True
Default Value:None
Allowed Type:unicode
for_

The interface this view is the default for.

Specifies the interface for which the view is registered.

All objects implementing this interface can make use of this view. If this attribute is not specified, the view is available for all objects.

Implementation:zope.configuration.fields.GlobalObject
Read Only:False
Required:False
Default Value:None
layer

The layer the default view is declared for

The default layer for which the default view is applicable. By default it is applied to all layers.

Implementation:zope.configuration.fields.GlobalInterface
Read Only:False
Required:False
Default Value:None

Value Type

Implementation:zope.schema.InterfaceField
Read Only:False
Required:True
Default Value:None
zope.publisher.zcml.setDefaultSkin(name, info='')[source]

Set the default skin.

>>> from zope.interface import directlyProvides
>>> from zope.app.testing import ztapi
>>> class Skin1: pass
>>> directlyProvides(Skin1, IBrowserSkinType)
>>> ztapi.provideUtility(IBrowserSkinType, Skin1, 'Skin1')
>>> setDefaultSkin('Skin1')
>>> adapters = component.getSiteManager().adapters

Look up the default skin for a request that has the

>>> adapters.lookup((IBrowserRequest,), IDefaultSkin, '') is Skin1
True