开发者

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 pr开发者_如何学运维actices 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜