zope.configuration.interfaces

Zope Configuration (ZCML) interfaces

exception zope.configuration.interfaces.InvalidToken[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Invaid token in list.

interface zope.configuration.interfaces.IConfigurationContext[source]

Configuration Context

The configuration context manages information about the state of the configuration system, such as the package containing the configuration file. More importantly, it provides methods for importing objects and opening files relative to the package.

resolve(dottedname)

Resolve a dotted name to an object

A dotted name is constructed by concatenating a dotted module name with a global name within the module using a dot. For example, the object named “spam” in the foo.bar module has a dotted name of foo.bar.spam. If the current package is a prefix of a dotted name, then the package name can be relaced with a leading dot, So, for example, if the configuration file is in the foo package, then the dotted name foo.bar.spam can be shortened to .bar.spam.

If the current package is multiple levels deep, multiple leading dots can be used to refer to higher-level modules. For example, if the current package is x.y.z, the dotted object name ..foo refers to x.y.foo.

package

The current package name

This is the name of the package containing the configuration file being executed. If the configuration file was not included by package, then this is None.

Implementation:zope.schema.BytesLine
Read Only:False
Required:False
Default Value:None
Allowed Type:str
provideFeature(name)

Record that a named feature is available in this context.

checkDuplicate(filename)

Check for duplicate imports of the same file.

Raises an exception if this file had been processed before. This is better than an unlimited number of conflict errors.

hasFeature(name)

Check whether a named feature is available in this context.

processFile(filename)

Check whether a file needs to be processed.

Return True if processing is needed and False otherwise. If the file needs to be processed, it will be marked as processed, assuming that the caller will procces the file if it needs to be procssed.

action(discriminator, callable, args=(), kw={}, order=0, includepath=None, info=None)

Record a configuration action

The job of most directives is to compute actions for later processing. The action method is used to record those actions.

Parameters:
  • callable – The object to call to implement the action.
  • args (tuple) – Arguments to pass to callable
  • kw (dict) – Keyword arguments to pass to callable
  • discriminator (object) – Used to to find actions that conflict. Actions conflict if they have equal discriminators. The exception to this is the special case of the discriminator with the value None. An action with a discriminator of None never conflicts with other actions.
  • order (int) – This is possible to add an order argument to crudely control the order of execution.
  • info (str) – Optional source line information
  • includepath – is None (the default) or a tuple of include paths for this action.
path(filename)

Compute a full file name for the given file

If the filename is relative to the package, then the returned name will include the package path, otherwise, the original file name is returned.

Environment variables in the path are expanded, and if the path begins with the username marker (~), that is expanded as well.

Changed in version 4.2.0: Start expanding home directories and environment variables.