Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: What ways of making data available to plugins?

I'm implementing a simple plugin framework for a little Python program and wonder what the different existing practices are for passing data to plugins.

At this stage, I see two alternatives:

  1. pass task-specific data to plugins, don't give plugins access to any other data
  2. pass all the data to which any plugin should have access

What are the pros and cons of these two approaches? Are there any other ways or best practices that I am unaware of? What do I have to take into consideration when deciding the way?

Note: I am asking for examples and general advice.

like image 362
lecodesportif Avatar asked Mar 09 '26 06:03

lecodesportif


1 Answers

I like the way wxPython does events. Pass an event object to the plugin with what you think is the relevant data, but also provide an API for every plugin to access the full state of the application.

For example, in wxMouseEvent has x and y properties. But also (like every other event object) has get GetEventObject (and every object has GetParent ....)

like image 149
lazy1 Avatar answered Mar 11 '26 18:03

lazy1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!