470,616 Members | 2,262 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,616 developers. It's quick & easy.

Python plug-in

Hi,

I'm trying to find some howto, tutorial in order to create a python program
that will allow plug-in programming. I've found various tutos on how to
write a plug-in for soft A or soft B but none telling me how to do it in my
own programs. Do you have any bookmarks ??

Regards,

Laurent.
Mar 28 '06 #1
2 1109
toto wrote:
Hi,

I'm trying to find some howto, tutorial in order to create a python program
that will allow plug-in programming. I've found various tutos on how to
write a plug-in for soft A or soft B but none telling me how to do it in my
own programs. Do you have any bookmarks ??


Trac and MoinMoin have a plugin system IIRC.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Mar 29 '06 #2
toto wrote:
I'm trying to find some howto, tutorial in order to create a python program
that will allow plug-in programming. I've found various tutos on how to
write a plug-in for soft A or soft B but none telling me how to do it in my
own programs. Do you have any bookmarks ?

There is more than one way to accomplish this, but one of the
simplest is to provide a directory where plugins are loaded, and
put an __init__.py in it which automatically finds files in the directory
that conform to some standard, and imports them (or tries to).

Here's a snippet from one of my projects:

import sys, os
from Operators import Operator, operate, Ops

# Find and load all available plugin modules:

operator_path = os.path.abspath(__path__[0])
for module_file in filter(
lambda n: n[-3:]=='.py' and n not in ('__init__.py', 'Operators.py'),
os.listdir(operator_path)):
#print "Loading %s" % module_file
f, e = os.path.splitext(module_file)
__import__(f, globals(), locals(), [])
(Operators.py is in the same directory and includes general purpose
code that the plugins use -- I think it might be better design to put
that in the parent directory. But that's awkward until Python
introduces relative import notation -- supposed to be coming in v2.5).

Mar 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Carl | last post: by
4 posts views Thread by djanvk | last post: by
2 posts views Thread by Petri Savolainen | last post: by
7 posts views Thread by Steve | last post: by
10 posts views Thread by AKA gray asphalt | last post: by
29 posts views Thread by Gerald | last post: by
7 posts views Thread by Chris | last post: by
20 posts views Thread by ram.rachum | last post: by
68 posts views Thread by Santiago Romero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.