mewlo.mpacks.core.registry.mregistry module

mregistry.py This module contains classes and functions for managing a component/service registry.

Here’s how it works:

A ComponentRegistry object holds a list of “Component” objects. A Component object is simply a thin wrapper around an arbitrary object, annotating it with a “feature

dictionary.
This feature dictionary is then used by consumers of the ComponentRegistry, so that they may ask the
ComponentRegistry to look up a component that possesses certain features.

Everything else, from the class of the wrapped Component objects to the kinds of features, is all handled by convention.

This is a very minimalist system for registering objects and making it possible for them to be discovered by other parts of code.

For an alternate way of supporting discovery of and communication between objects, one could use the Signal system.

Some fields for the Component “feature” dictionary:
  • ‘name’ - should always be specified to aid in debugging (need not be unique)
  • ‘version’ - integer numeric version useful for filtering and compatibility checks
  • ATTN: TODO add more
How to use the feature filter to look up matching components:
  • ATTN: TODO - We use a generic filtering system (see does_dict_filter_match(); it’s also used for log messages).
class mewlo.mpacks.core.registry.mregistry.MewloComponent(id, owner, features, obj)[source]

Bases: object

A component object that can be added to the ComponentRegsitry.

does_match_feature_filter(feature_filter)[source]

Return True if feature_filter matches features of the component.

dumps(indent=0)[source]

Debug information.

get_features()[source]

We use a function here in case subclass wants to override.

class mewlo.mpacks.core.registry.mregistry.MewloRegistryManager(mewlosite, debugmode)[source]

Bases: mewlo.mpacks.core.manager.manager.MewloManager

The component registry.

description = 'Manages a global registry of objects so that other components can find each other and registered objects/classes/etc.'
dumps(indent=0)[source]

Debug information.

find_all_matching_components(feature_filter)[source]

Find matching components using the feature_filter passed.

find_one_matching_component(feature_filter, flag_errorifnotfound=True, flag_errorifmorethanone=True)[source]

Find one and only one matching components using the feature_filter passed.

get_class(id)[source]

Proxy for registering a class object, creates a simple component around it.

getid(id)[source]
idfromclassobjectname(objname)[source]
register_class(owner, classobj)[source]

Proxy for registering a class object, creates a simple component around it.

register_component(component)[source]

Add a component to the registry.

shutdown()[source]
shutdown_obj_ifownedby(obj, owner)[source]

If a component has the owner specified, shut it down and return True; otherwise return False.

typestr = 'core'
unregister_all()[source]

Shutdown all registered components.

unregister_byowner(owner)[source]

Unregister anything owned by the specified ownerobject.