cybertools/meta
2019-04-26 17:42:10 +02:00
..
__init__.py create cybertools.meta package for managing configuration options and other meta and control data 2008-04-10 13:29:06 +00:00
config.py make configuration queries more fault-tolerant 2009-10-12 06:04:17 +00:00
element.py options/config management basically working 2008-04-12 14:00:13 +00:00
interfaces.py options/config management basically working 2008-04-12 14:00:13 +00:00
namespace.py options/config management basically working 2008-04-12 14:00:13 +00:00
namespace.txt work in progress: cybertools.meta - configuration settings framework 2008-04-11 15:09:01 +00:00
README.txt options/config management basically working 2008-04-12 14:00:13 +00:00
tests.py fix tests/doctests according to current ZTK and BlueBream versions 2019-04-26 17:42:10 +02:00

===========================
Meta Information Management
===========================

  ($Id$)


Configuration Options, Settings, Preferences
============================================

  >>> from cybertools.meta.config import Options

  >>> config = Options()

The Options object allows us to access arbitrary attributes that will
be created as elements within the Options object.

  >>> config.storage
  <AutoElement 'storage'>

  >>> config.i18n.languages = ['de', 'en', 'it']

  >>> config.i18n.languages
  ['de', 'en', 'it']

  >>> config('i18n.languages')
  ['de', 'en', 'it']

Loading options as Python code
------------------------------

  >>> from cybertools.meta.namespace import Executor
  >>> config = Options()
  >>> ex = Executor(config)

  >>> code = """
  ... controller(names=('cmdline', 'telnet'))
  ... controller.telnet(port= 5001)
  ... scheduler(name='core')
  ... logger(name='default', standard=30)
  ... """

  >>> result = ex.execute(code)

  >>> config.scheduler.name
  'core'
  >>> config.logger.standard
  30
  >>> config.controller.names
  ('cmdline', 'telnet')
  >>> config.controller.telnet.port
  5001

  >>> print config
  controller.telnet(port=5001)
  controller(names=('cmdline', 'telnet'))
  scheduler(name='core')
  logger(name='default', standard=30)