473,804 Members | 2,536 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 1232
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
1748
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 trap for specific web service errors without parsing the error message? Thanks.
13
94440
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
3673
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
1689
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
2955
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 requirements (within the scope of the plug-in interface spec of course). In the past I've done this with...
0
1024
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 for is some kind of wrapper class for the c++ library, or at least some help on how to do the...
1
1441
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 on another computer it doesn't work. I have installed the networked printer's driver to the server...
1
1353
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 assembly = Assembly.LoadFile(pDllName);
2
1421
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 changes and modified the version to 1.1. Then agian i delployed the activex using install shiled and...
0
9591
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10087
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6861
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.