leejd:
About the Python Extension (pythonext)
[阅读: 602] 2008-09-04 02:07:40
About the Python Extension (pythonext)
This project provides Python Mozilla bindings that enables Python to be used inside of Mozilla applications. The Python bindings are wrapped up in an extension (XPI file) so that users can easily install PythonExt just like any other Mozilla/Firefox extension. The Python bindings are a combination of PyXPCOM and PyDOM.
The Python extension is using Python 2.5.2 and is available to be used in most Mozilla based applications, including Firefox, Thunderbird and XulRunner.
Why do this?
It gives the power of Python to Mozilla extension developers
Easy to setup multi-threaded tasks
Rapidly build cross platform extensions, no compilation issues!
Great base of core library functionality
Not limited to JavaScript
Provides a Python GUI toolkit to build applications (XULRunner)
What does Python bring to Mozilla?
ctypes support, easily accessing the native OS libraries
additional network protocol support, like SFTP, SCP access through Paramiko
create UDP sockets (see Mozilla bug 191187)
thousands of additional python packages
What are the limitations
The extension is large, between 5-15MB
PythonExt uses a separate extension (xpi file) for every operating system supported
What's inside the extension?
The Python 2.5.2 interpreter, libraries and necessary files
The bindings to enable Python to communicate with Mozilla XPCOM and DOM
How does it all work?
The Python extension is download and installed into a Mozilla application as a regular extension
Upon starting of the application, the extension is registered, and loads the internal dynamic linked libraries (python, pyxpcom and pydom)
Additional extension directories are then checked to see if there are any extensions using pyxpcom that need to be registered (and appropriately registers them)
The internal Python path (sys.path) is updated to reflect any "pylib" directories found in the installed extensions