zope.site API

Interfaces

Interfaces for the Local Component Architecture

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

Bases: object

Event: a local site was created

Implementations

Site

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: BTreeContainer, PersistentComponents

Local Site Manager (ILocalSiteManager) implementation

addSub(sub)[source]

See zope.site.interfaces.ILocalSiteManager.addSub()

removeSub(sub)[source]

See zope.site.interfaces.ILocalSiteManager.removeSub()

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

Bases: object

Implementation of a IDirectoryFactory that creates SiteManagementFolder

class zope.site.site.SiteManagementFolder[source]

Bases: BTreeContainer

Implementation of a ISiteManagementFolder

class zope.site.site.SiteManagerContainer[source]

Bases: 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.SiteManagerAdapter(ob)[source]

An adapter from ILocation to IComponentLookup.

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

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

After a site is (re-)moved, its site manager links have to be updated.

Subscriber to ISite objects in a IObjectMovedEvent.

zope.site.site.clearThreadSiteSubscriber(event)[source]

A subscriber to zope.publisher.interfaces.EndRequestEvent

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

Note

The configure.zcml included in this package does not install this subscriber. That must be configured separately. zope.app.publication includes such configuration.

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

A multi-subscriber to zope.component.interfaces.ISite and zope.traversing.interfaces.BeforeTraverseEvent.

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

Note

The configure.zcml included in this package does not install this subscriber. That must be configured separately. zope.app.publication includes such configuration.

Folder

class zope.site.folder.Folder[source]

Bases: Folder, SiteManagerContainer

Implementation of zope.site.interfaces.IFolder

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

Bases: object

Adapter for an zope.site.interfaces.IFolder to zope.location.interfaces.ISublocations.

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.interface.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
[]
zope.site.folder.rootFolder()[source]

Factory for a zope.site.interfaces.IRootFolder