| Trees | Index | Help |
|
|---|
| Package zope :: Package configuration :: Module config :: Class ConfigurationMachine |
|
object --+
|
ConfigurationAdapterRegistry --+
|
object --+ |
| |
ConfigurationContext --+
|
ConfigurationMachine
Configuration machine
Example:
>>> machine = ConfigurationMachine() >>> ns = "http://www.zope.org/testing"
Register a directive:
>>> machine((metans, "directive"), ... namespace=ns, name="simple", ... schema="zope.configuration.tests.directives.ISimple", ... handler="zope.configuration.tests.directives.simple")
and try it out:
>>> machine((ns, "simple"), a=u"aa", c=u"cc")
>>> machine.actions
[(('simple', u'aa', u'xxx', 'cc'), f, (u'aa', u'xxx', 'cc'))]
A more extensive example can be found in the unit tests.
| Method Summary | |
|---|---|
__init__(self)
| |
__call__(self,
_ConfigurationMachine__name,
_ConfigurationMachine__info,
**_ConfigurationMachine__kw)
| |
begin(self,
_ConfigurationMachine__name,
_ConfigurationMachine__data,
_ConfigurationMachine__info,
**kw)
| |
end(self)
| |
Execute the configuration actions | |
getInfo(self)
| |
setInfo(self,
info)
| |
| Inherited from ConfigurationAdapterRegistry | |
| |
| |
| |
| Inherited from ConfigurationContext | |
Add an action with the given discriminator, callable and arguments | |
Check for duplicate imports of the same file. | |
Check whether a named feature has been provided. | |
Examples: | |
Check whether a file needs to be processed | |
Declare thata named feature has been provided. | |
Resolve a dotted name to an object | |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
| Class Variable Summary | |
|---|---|
Implements |
__implemented__ = <implementedBy zope.configuration.conf...
|
ClassProvides |
__provides__ = <zope.interface.declarations.ClassProvide...
|
NoneType |
basepath = None |
tuple |
includepath = ()
|
str |
info = ''
|
NoneType |
package = None |
| Inherited from ConfigurationAdapterRegistry | |
ClassProvides |
__providedBy__ = <zope.interface.declarations.ClassProvi...
|
| Method Details |
|---|
execute_actions(self, clear=True, testing=False)Execute the configuration actions This calls the action callables after resolving conflicts For example:
>>> output = []
>>> def f(*a, **k):
... output.append(('f', a, k))
>>> context = ConfigurationMachine()
>>> context.actions = [
... (1, f, (1,)),
... (1, f, (11,), {}, ('x', )),
... (2, f, (2,)),
... ]
>>> context.execute_actions()
>>> output
[('f', (1,), {}), ('f', (2,), {})]
If the action raises an error, we convert it to a ConfigurationExecutionError.
>>> output = []
>>> def bad():
... bad.xxx
>>> context.actions = [
... (1, f, (1,)),
... (1, f, (11,), {}, ('x', )),
... (2, f, (2,)),
... (3, bad, (), {}, (), 'oops')
... ]
>>> try:
... v = context.execute_actions()
... except ConfigurationExecutionError, v:
... pass
>>> print v
exceptions.AttributeError: 'function' object has no attribute 'xxx'
in:
oops
Note that actions executed before the error still have an effect:
>>> output
[('f', (1,), {}), ('f', (2,), {})]
|
| Class Variable Details |
|---|
__implemented__
|
__provides__
|
basepath
|
includepath
|
info
|
package
|
| Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Fri Jun 24 12:01:21 2005 | http://epydoc.sf.net |