zope.site API


Interfaces for the Local Component Architecture

interface zope.site.interfaces.IFolder[source]

Extends: zope.container.interfaces.IContainer, zope.component.interfaces.IPossibleSite, zope.annotation.interfaces.IAttributeAnnotatable

The standard Zope Folder object interface.

interface zope.site.interfaces.ILocalSiteManager[source]

Extends: zope.interface.interfaces.IComponents

Site Managers act as containers for registerable components.

If a Site Manager is asked for an adapter or utility, it checks for those it contains before using a context-based lookup to find another site manager to delegate to. If no other site manager is found they defer to the global site manager which contains file based utilities and adapters.


Remove a sub-registry to the node.

Important: This method should not be used manually. It is automatically called by setNext(). To remove a registry from the tree, use sub.setNext(None) instead!


Add a new sub-registry to the node.

Important: This method should not be used manually. It is automatically called by setNext(). To add a new registry to the tree, use sub.setNext(self, self.base) instead!


A collection of registries that describe the next level of the registry tree. They are the children of this registry node. This attribute should never be manipulated manually. Use addSub() and removeSub() instead.

interface zope.site.interfaces.INewLocalSite[source]

Event: a local site was created


The new site manager

interface zope.site.interfaces.IRootFolder[source]

Extends: zope.site.interfaces.IFolder, zope.location.interfaces.IRoot

The standard Zope root Folder object interface.

interface zope.site.interfaces.ISiteManagementFolder[source]

Extends: zope.container.interfaces.IContainer

Component and component registration containers.

class zope.site.interfaces.NewLocalSite(manager)[source]

Bases: object

Event: a local site was created



Site and Local Site Manager implementation

A local site manager has a number of roles:

  • A local site manager, that provides a local adapter and utility registry.
  • A place to do TTW development and/or to manage database-based code.
  • A registry for persistent modules. The Zope 3 import hook uses the SiteManager to search for modules.
class zope.site.site.LocalSiteManager(site, default_folder=True)[source]

Bases: zope.container.btree.BTreeContainer, zope.component.persistentregistry.PersistentComponents

Local Site Manager (ILocalSiteManager) implementation


See interfaces.registration.ILocatedRegistry


See interfaces.registration.ILocatedRegistry

class zope.site.site.SMFolderFactory(context)[source]

Bases: object

Implementation of a IDirectoryFactory that creates SiteManagementFolder

class zope.site.site.SiteManagementFolder[source]

Bases: zope.container.btree.BTreeContainer

Implementation of a ISiteManagementFolder


An adapter from ILocation to IComponentLookup.

The ILocation is interpreted flexibly, we just check for __parent__.

class zope.site.site.SiteManagerContainer[source]

Bases: zope.container.contained.Contained

Implement access to the site manager (++etc++site).

This is a mix-in that implements the IPossibleSite interface; for example, it is used by the Folder implementation.

zope.site.site.changeSiteConfigurationAfterMove(site, event)[source]

After a site is moved, its site manager links have to be updated.

Subscriber to ISite objects in a IObjectMovedEvent.


A subscriber to EndRequestEvent

Cleans up the site thread global after the request is processed.

zope.site.site.threadSiteSubscriber(ob, event)[source]

A subscriber to BeforeTraverseEvent

Sets the ‘site’ thread global if the object traversed is a site.


class zope.site.folder.Folder[source]

Bases: zope.container.folder.Folder, zope.site.site.SiteManagerContainer

Implementation of IFolder

class zope.site.folder.FolderSublocations(folder)[source]

Bases: object

Get the sublocations of a folder

The subobjects of a folder include it’s contents and it’s site manager if it is a site.

>>> from zope.container.contained import Contained
>>> folder = Folder()
>>> folder['ob1'] = Contained()
>>> folder['ob2'] = Contained()
>>> folder['ob3'] = Contained()
>>> subs = list(FolderSublocations(folder).sublocations())
>>> subs.remove(folder['ob1'])
>>> subs.remove(folder['ob2'])
>>> subs.remove(folder['ob3'])
>>> subs
>>> sm = Contained()
>>> from zope.interface import directlyProvides
>>> from zope.component.interfaces import IComponentLookup
>>> directlyProvides(sm, IComponentLookup)
>>> folder.setSiteManager(sm)
>>> directlyProvides(folder, zope.component.interfaces.ISite)
>>> subs = list(FolderSublocations(folder).sublocations())
>>> subs.remove(folder['ob1'])
>>> subs.remove(folder['ob2'])
>>> subs.remove(folder['ob3'])
>>> subs.remove(sm)
>>> subs

Factory for a IRootFolder