mewlo.mpacks.core.registry.mregistry module 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

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.


Return True if feature_filter matches features of the component.


Debug information.


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.'

Debug information.


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.


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

register_class(owner, classobj)[source]

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


Add a component to the registry.

shutdown_obj_ifownedby(obj, owner)[source]

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

typestr = 'core'

Shutdown all registered components.


Unregister anything owned by the specified ownerobject.