Package zope :: Package configuration :: Module xmlconfig
[show private | hide private]
[frames | no frames]

Module zope.configuration.xmlconfig

Support for the XML configuration file format

Note, for a detailed description of the way that conflicting configuration actions are resolved, see the detailed example in test_includeOverrides in tests/text_xmlconfig.py

$Id: xmlconfig.py,v 1.2 2005/06/24 16:52:27 nyergler Exp $


Classes
ConfigurationHandler Interface to the xml parser
IInclude The zope:include directive
ParserInfo Information about a directive based on parser data
XMLConfig Provide high-level handling of configuration files.

Exceptions
ZopeSAXParseException Sax Parser errors, reformatted in an emacs friendly way
ZopeXMLConfigurationError Zope XML Configuration error

Function Summary
  file(name, package, context, execute)
Execute a zcml file
  include(_context, file, package, files)
Include a zcml file
  includeOverrides(_context, file, package)
Include zcml file containing overrides
  openInOrPlain(filename)
Open a file, falling back to filename.in.
  processxmlfile(file, context, testing)
Process a configuration file
  registerCommonDirectives(context)
  string(s, context, name, execute)
Execute a zcml string
  testxmlconfig(file, context)
xmlconfig that doesn't raise configuration errors
  xmlconfig(file, testing)
  _clearContext()
  _getContext()

Variable Summary
Logger logger = <logging.Logger instance at 0xb64c554c>
tuple ZCML_CONDITION = ('http://namespaces.zope.org/zcml', u'c...
str ZCML_NAMESPACE = 'http://namespaces.zope.org/zcml'
NoneType _context = None                                                                  

Function Details

file(name, package=None, context=None, execute=True)

Execute a zcml file

include(_context, file=None, package=None, files=None)

Include a zcml file

See examples in tests/text_xmlconfig.py

includeOverrides(_context, file, package=None)

Include zcml file containing overrides

The actions in the included file are added to the context as if they were in the including file directly.

See the detailed example in test_includeOverrides in tests/text_xmlconfig.py

openInOrPlain(filename)

Open a file, falling back to filename.in.

If the requested file does not exist and filename.in does, fall back to filename.in. If opening the original filename fails for any other reason, allow the failure to propogate.

For example, the tests/samplepackage dirextory has files:

configure.zcml configure.zcml.in foo.zcml.in

If we open configure.zcml, we'll get that file:

>>> here = os.path.dirname(__file__)
>>> path = os.path.join(here, 'tests', 'samplepackage', 'configure.zcml')
>>> f = openInOrPlain(path)
>>> f.name[-14:]
'configure.zcml'

But if we open foo.zcml, we'll get foo.zcml.in, since there isn't a foo.zcml:

>>> path = os.path.join(here, 'tests', 'samplepackage', 'foo.zcml')
>>> f = openInOrPlain(path)
>>> f.name[-11:]
'foo.zcml.in'

Make sure other IOErrors are re-raised. We need to do this in a try-except block because different errors are raised on Windows and on Linux.

>>> try:
...     f = openInOrPlain('.')
... except IOError:
...     print "passed"
... else:
...     print "failed"
...
passed

processxmlfile(file, context, testing=False)

Process a configuration file

See examples in tests/text_xmlconfig.py

string(s, context=None, name='<string>', execute=True)

Execute a zcml string

testxmlconfig(file, context=None)

xmlconfig that doesn't raise configuration errors

This is useful for testing, as it doesn't mask exception types.


Variable Details

logger

Type:
Logger
Value:
<logging.Logger instance at 0xb64c554c>                                

ZCML_CONDITION

Type:
tuple
Value:
('http://namespaces.zope.org/zcml', u'condition')                      

ZCML_NAMESPACE

Type:
str
Value:
'http://namespaces.zope.org/zcml'                                      

_context

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.1 on Fri Jun 24 12:01:21 2005 http://epydoc.sf.net