Phoenix Logo

phoenix_title wx.lib.pubsub.core.listenerbase.ValidatorBase

Validates listeners. It checks whether the listener given to validate() method complies with required and optional arguments specified for topic.


class_hierarchy Class Hierarchy

Inheritance diagram for class ValidatorBase:


method_summary Methods Summary

__init__ topicArgs is a list of argument names that will be required when sending
isValid Return true only if listener can subscribe to messages where
validate Validate that listener satisfies the requirements of

api Class API



class ValidatorBase

Validates listeners. It checks whether the listener given to validate() method complies with required and optional arguments specified for topic.


Methods



__init__(self, topicArgs, topicKwargs)

topicArgs is a list of argument names that will be required when sending a message to listener. Hence order of items in topicArgs matters. The topicKwargs is a list of argument names that will be optional, ie given as keyword arguments when sending a message to listener. The list is unordered.



isValid(self, listener)

Return true only if listener can subscribe to messages where topic has kwargs keys topicKwargKeys. Just calls validate() in a try-except clause.



validate(self, listener)

Validate that listener satisfies the requirements of being a topic listener, if topic’s kwargs keys are topicKwargKeys (so only the list of keyword arg names for topic are necessary). Raises ListenerMismatchError if listener not usable for topic.

Otherwise, returns an CallArgsInfo object containing information about the listener’s call arguments, such as whether listener wants topic name (signified by a kwarg value = AUTO_TOPIC in listener protocol). E.g. def fn1(msgTopic=Listener.AUTO_TOPIC) would cause validate(fn1) to return True, whereas any other kwarg name or value would cause a False to be returned.