apptools.naming.context module

The base class for all naming contexts.

class apptools.naming.context.Context[source]

Bases: traits.has_traits.HasTraits

The base class for all naming contexts.

INITIAL_CONTEXT_FACTORY = 'apptools.naming.factory.initial'
OBJECT_FACTORIES = 'apptools.naming.factory.object'
STATE_FACTORIES = 'apptools.naming.factory.state'
bind(name, obj, make_contexts=False)[source]

Binds a name to an object.

If ‘make_contexts’ is True then any missing intermediate contexts are created automatically.

create_subcontext(name)[source]

Creates a sub-context.

destroy_subcontext(name)[source]

Destroys a sub-context.

get_unique_name(prefix)[source]

Returns a name that is unique within the context.

The name returned will start with the specified prefix.

is_context(name)[source]

Returns True if the name is bound to a context.

list_bindings(name='')[source]

Lists the bindings in a context.

list_names(name='')[source]

Lists the names bound in a context.

lookup(name)[source]

Resolves a name relative to this context.

lookup_binding(name)[source]

Looks up the binding for a name relative to this context.

lookup_context(name)[source]

Resolves a name relative to this context.

The name MUST resolve to a context.

rebind(name, obj, make_contexts=False)[source]

Binds an object to a name that may already be bound.

If ‘make_contexts’ is True then any missing intermediate contexts are created automatically.

The object may be a different object but may also be the same object that is already bound to the specified name. The name may or may not be already used. Think of this as a safer version of ‘bind’ since this one will never raise an exception regarding a name being used.

rename(old_name, new_name)[source]

Binds a new name to an object.

search(obj)[source]

Returns a list of namespace names that are bound to obj.

unbind(name)[source]

Unbinds a name.