473,573 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Plug-Ins In A Python Application

Its the Java developer again...

I'm working on an application framework that I would like to implement
in Python. Part of the application framework is a plug-in model that is
similar to the one used in Eclipse.

Is it possible to load and use "modules" containing plug-in code
written by third party developers into a running instance of the
framework? How would I do this? Do I need to "dynamicall y load" the
module at runtime? (I will scan a folder in the application direcotry
for XML files containing information about the plug-ins, including the
modules that implement them.)

Thanks,

Scott Huey

Apr 18 '06 #1
3 1220
re************* ***@gmail.com wrote:
Its the Java developer again...

I'm working on an application framework that I would like to implement
in Python. Part of the application framework is a plug-in model that is
similar to the one used in Eclipse.

Is it possible to load and use "modules" containing plug-in code
written by third party developers into a running instance of the
framework? How would I do this? Do I need to "dynamicall y load" the
module at runtime? (I will scan a folder in the application direcotry
for XML files containing information about the plug-ins, including the
modules that implement them.)

Thanks,

Scott Huey

Look at the "imp" module.

Any module can be imported at any time in your code. The import
statement is usually used to the top of a file, making it *look* like a
declaration, but in fact it may be executed anywhere. The import
statements does, however, hard code its module's name. For a plugin
system, you'll probably want to import a module given a string
containing its name. The "imp" module provides this as well as access
to many of the features of the import mechanism.

Gary Herron

Apr 18 '06 #2

On Apr 18, 2006, at 9:58 AM, re************* ***@gmail.com wrote:
Its the Java developer again...

I'm working on an application framework that I would like to implement
in Python. Part of the application framework is a plug-in model that is
similar to the one used in Eclipse.

Is it possible to load and use "modules" containing plug-in code
written by third party developers into a running instance of the
framework? How would I do this? Do I need to "dynamicall y load" the
module at runtime? (I will scan a folder in the application direcotry
for XML files containing information about the plug-ins, including the
modules that implement them.)


Well, the "state of the art" in Python plugins is moving towards Eggs:
http://peak.telecommunity.com/DevCenter/PythonEggs

Though that might be a bit much for you to jump into considering you're
just starting out in Python. However, if you do learn it now, you won't
have to learn it again later when everyone's using it :)

Jay P.

Apr 18 '06 #3
re************* ***@gmail.com wrote:
Is it possible to load and use "modules" containing plug-in code
written by third party developers into a running instance of the
framework? How would I do this? Do I need to "dynamicall y load" the
module at runtime? (I will scan a folder in the application direcotry
for XML files containing information about the plug-ins, including the
modules that implement them.)


a simple approach is to do something like

for file in list_of_plugins :
ns = {}
execfile(file, ns)
# pick up interesting objects from the namespace dictionary
# e.g.
callback = ns["callback"]

where individual plugins might look something like

# my plugin

def callback(event) :
pass # do something here

You can prepopulate the namespace to make application-specific
objects available for the plugins:

context = MyContext()

for file in list_of_plugins :
ns = dict(context=co ntext)
execfile(file, ns)

which allows the plugins to do e.g.

# my plugin

def callback(event) :
pass

context.registe r(callback)

or you can use a plugin initialization function:

context = MyContext()

for file in list_of_plugins :
ns = {}
execfile(file, ns)
setup = ns["setup"]
setup(context)

where the plugins look like:

def callback(event) :
pass

def setup(context):
context.registe r(callback)

and so on. To learn more about this, look up exec/execfile and
__import__ in the library reference.

</F>

Apr 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1740
by: Patrick | last post by:
I'm trying to figure out the best way to trap for specific errors when making calls to a web service. For instance, if the web service returns an "invalid login" error, I want to be able to trap the error and take the user to a login page. All of the errors return from my web services come back as RemoteException objects. Is there a way to...
13
94415
by: Mike | last post by:
Apparently there is now a way to hide html source code. How it done? For example see: See http://www.eteamz.com/banksblaze/
6
3665
by: Graham Ashton | last post by:
Hi. I'm trying to edit C# code from within eclipse 2.1.1 but am getting nowhere. The Improve plug-in doesn't seem to install on such recent versions of eclipse; is there anything else out there that I could try? Thanks, Graham
3
1680
by: Muhammad Aftab Alam | last post by:
Hello All is it possible to write plug-in for IIS with c#, if so what path should I follow to get to what I want. best regards Muhammad Aftab Alam
6
2937
by: Gary James | last post by:
This may not be a direct C# question, but since I'll be using using C# for development, I thought I'd pose the question here. I'll soon be involved in the design of a new software product that will employ a software "Plug-In" architecture. Taking the plug-in route will give us a design that can adapt to, as yet, undefined future...
0
1018
by: hespamme | last post by:
Has anyone out there implemented an MFX plug in with c#? All of the googling I can find is for c++. My issue is that I have a stand alone midi app written in c# that I now want to use as a plug in for a capable sequencer (such as Sonar) Currently my program outputs midi files that I manually import into Sonar. I think what I'm looking...
1
1432
by: Homa | last post by:
I have a web service that want to print something to a printer connected on another computer in the network. And that printer happens to be a non-plug and play printer (It's a thermal printer). I tried to install the printer to the server directly and it works fine (I use PrinterSettings.PrinterName to set the printer). But when I set it up...
1
1343
by: DeveloperX | last post by:
I've knocked up a quick plug in project (actually it's 6 projects, but more on that in a moment). This project is referenced by a shared add in (used for Excel). The issue I have is that when I iterate through the DLL's in the plug in's directory, when it finds my plug in dll it claims there are no types in the assembly. Assembly...
2
1410
by: iftikar | last post by:
Hi. I have created one activex plug-in using .NET named as a Automation. It is a windows control libray. In that activex class i have one function called version where i have given the value as 1.0. And then i have deployed this plug-in using Instal Shield. It has got installed and working properly. Now i have modifed the Activex for some code...
0
7686
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8016
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7773
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8061
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6411
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5289
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3731
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1297
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1038
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.