Defining the Plugin Modules

So far, we have only two requirements that the plug-in classes must satisfy: each class must inherit from the base Plugin class, and their__init__method must accept the keyword arguments. The class may choose to completely ignore what has been passed to it during the initialization, but it still must accept the arguments; otherwise, we'll get the invalid argument list exception when the main application passes the arguments we don't expect to receive. The plug-in module skeleton looks like this:

#!/usr/bin/env python from manager import Plugin class CountHTTP200(Plugin):

pass

This plug-in obviously doesn't do much yet. We now need to define the interfaces between the main application and the plug-in. In our log-parsing application example, the communication is going to be only one way: the application sends the messages (log information) to the plug-ins for further processing. In addition, the application may send other commands or signals that inform the plug-in objects about the current state of the application. So now we need to create the host application.

Was this article helpful?

0 0

Post a comment