Table of Contents

Class: Namespace ./src/peak/config/config_components.py

Traverse to another property namespace

Use this in .ini files (e.g. '__main__. = config.Namespace("environ.")') to create a rule that looks up undefined properties in another property namespace.

Or, use this as a way to treat a property namespace as a mapping object:

        myNS = config.Namespace("some.prefix", aComponent)
        myNS['spam.bayes']              # property 'some.prefix.spam.bayes'
        myNS.get('something',default)   # property 'some.prefix.something'

Or use this in a component class to allow traversing to a property space:

        class MyClass(binding.Component):

            appConfig = binding.Make(
                config.Namespace('MyClass.conf')
            )

            something = binding.Obtain('appConfig/foo.bar.baz')

In the example above, something will be the component's value for the property MyClass.conf.foo.bar.baz. Note that you may not traverse to names beginning with an _, and traversing to the name get will give you the namespace's get method, not the get property in the namespace. To obtain the get property, or properties beginning with _, you must use the mapping style of access, as shown above.

NOTE: By default, Namespace instances cache every key that's looked up in them. If you are holding a reference to a namespace, and you expect an unbounded number of potential lookups, do not want references held to the results, or are looking up dynamically changing or dynamically created properties, you should disable caching via the cache=False keyword arg.

Base Classes   
object
Methods   
__call__
__getattr__
__getitem__
__init__
__repr__
get
keys
  __call__ 
__call__ ( self,  suffix )

Return a sub-namespace for suffix

  __getattr__ 
__getattr__ ( self,  attr )

Exceptions   
AttributeError, attr
  __getitem__ 
__getitem__ ( self,  key )

Return the value of property key within this namespace

Exceptions   
KeyError, key
  __init__ 
__init__ (
        self,
        prefix,
        target=NOT_GIVEN,
        cache=True,
        )

  __repr__ 
__repr__ ( self )

  get 
get (
        self,
        key,
        default=None,
        )

Return property key within this namespace, or default

  keys 
keys ( self )


Table of Contents

This document was automatically generated on Mon Apr 29 01:11:05 2024 by HappyDoc version 2.1