Messages Module Functions

The protorpc.messages package provides the following positional utility function:

find_definition(name, relative_to=None)

Find definition by name in module-space.

The find algorithm finds definitions by name relative to a message definition or by fully qualified name. If no definition is found relative to the relative_to parameter, it searches against the container of relative_to. If relative_to is a nested Message, it searches its message_definition(). If that message has no message_definition(), it searches its module. If relative_to is a module, the find algorithm searches for the containing module and searches relative to it. If the module is a top-level module, the find algorithm searches for the a message using a fully qualified name. If it still finds no message, the search fails and the method raises a DefinitionNotFoundError.

For example, when looking for any definition foo.bar.ADefinition relative to an actual message definition abc.xyz.SomeMessage:

find_definition('foo.bar.ADefinition', SomeMessage)

The arguments to this method follow a pattern similar to a search for fully qualified names: