Interfaces

This package defines several basic interfaces.

IView

Views adapt both a context and a request.

There is not much we can test except that IView is importable and an interface:

>>> from zope.interface import Interface
>>> from zope.browser.interfaces import IView
>>> Interface.providedBy(IView)
True
interface zope.browser.interfaces.IView[source]

Views are multi-adapters for context and request objects.

context

The context object the view renders

request

The request object driving the view

IBrowserView

Browser views are views specialized for requests from a browser (e.g., as distinct from WebDAV, FTP, XML-RPC, etc.).

There is not much we can test except that IBrowserView is importable and an interface derived from IView:

>>> from zope.interface import Interface
>>> from zope.browser.interfaces import IBrowserView
>>> Interface.providedBy(IBrowserView)
True
>>> IBrowserView.extends(IView)
True
interface zope.browser.interfaces.IBrowserView[source]

Extends: zope.browser.interfaces.IView

Views which are specialized for requests from a browser

Such views are distinct from those geerated via WebDAV, FTP, XML-RPC, etc.

IAdding

Adding views manage how newly-created items get added to containers.

There is not much we can test except that IAdding is importable and an interface derived from IBrowserView:

>>> from zope.interface import Interface
>>> from zope.browser.interfaces import IAdding
>>> Interface.providedBy(IBrowserView)
True
>>> IAdding.extends(IBrowserView)
True
interface zope.browser.interfaces.IAdding[source]

Extends: zope.browser.interfaces.IBrowserView

Multi-adapter interface for views which add items to containers.

The ‘context’ of the view must implement zope.container.interfaces.IContainer.

add(content)

Add content object to context.

Add using the name in contentName.

Return the added object in the context of its container.

If contentName is already used in container, raise zope.container.interfaces.DuplicateIDError.

contentName

The content name, usually set by the Adder traverser.

If the content name hasn’t been defined yet, returns None.

Some creation views might use this to optionally display the name on forms.

nextURL()

Return the URL that the creation view should redirect to.

This is called by the creation view after calling add.

It is the adder’s responsibility, not the creation view’s to decide what page to display after content is added.

nameAllowed()

Return whether names can be input by the user.

addingInfo()

Return add menu data as a sequence of mappings.

Each mapping contains ‘action’, ‘title’, and possibly other keys.

The result is sorted by title.

isSingleMenuItem()

Return whether there is single menu item or not.

hasCustomAddView()

This should be called only if there is singleMenuItem else return 0.

ITerms

The ITerms interface is used as a base for ISource widget implementations. This interfaces get used by zope.app.form and was initially defined in zope.app.form.browser.interfaces, which made it impossible to use for other packages like z3c.form wihtout depending on zope.app.form.

Moving such base components / interfaces to zope.browser makes it possible to share them without undesirable dependencies.

There is not much we can test except that ITerms is importable and an interface:

>>> from zope.interface import Interface
>>> from zope.browser.interfaces import ITerms
>>> Interface.providedBy(ITerms)
True
interface zope.browser.interfaces.ITerms[source]

Adapter providing lookups for vocabulary terms.

getTerm(value)

Return an ITitledTokenizedTerm object for the given value

LookupError is raised if the value isn’t in the source.

The return value should have the token and title attributes.

getValue(token)

Return a value for a given identifier token

LookupError is raised if there isn’t a value in the source.

ISystemErrorView

Views providing this interface can classify their contexts as system errors. These errors can be handled in a special way (e. g. more detailed logging).

There is not much we can test except that ISystemErrorView is importable and an interface:

>>> from zope.interface import Interface
>>> from zope.browser.interfaces import ISystemErrorView
>>> Interface.providedBy(ISystemErrorView)
True
interface zope.browser.interfaces.ISystemErrorView[source]

Error views that can classify their contexts as system errors

isSystemError()

Return a boolean indicating whether the error is a system error.