wiki:PyXPCOM

PyXPCOM Plans

So once we've got PyXPCOM building and installing against a standard Firefox 2.0.0.2 we'll be working on the following plan. At the time of writing (Friday 23 March) some parts of the plan are already a certain way along. The complete parts can be found in the pyxpcom4 branch of our exe svn.

The Plan

  1. Build and install PyXPCOM against a standard Mozilla Firefox 2.0.0.2
  2. Write a xulapp, that can be loaded by a chrome url (chrome://exe/content/exe.xul) 2.1. This requires modifying and renaming the exe/xului/templates/mainpage.xul page to exe.xul.

2.1.1. We take out the bits that load the nevow script, and replace them

with some code that instantiates the exeApplication XPCOM component. Something like this: var exeApp = Components.classes['@exelearning.org/application;1'].getService(Components.interfaces.nsIEXEApplication)

2.1.2. We change all the action/command bits, eg.

<key n:render="addChild" id="addChildKey" keycode="VK_INSERT"/> becomes <key oncommand="mainPage.call('addChild', currentOutlineId());" id="addChildKey" keycode="VK_INSERT"/>

2.1.3. The other bits like n:render="translate" remain, as we will

later be porting the DOM parser found in exe/xului/propertiespage.py:203. To find these n:render="translate" blocks and translate them.

2.2. We need to write an exe.manifest file that sits in

firefox/chrome directory pointing to wherever we have installed the exe xulapp. Something like this: content exe /home/matiu/projects/exe/xulapp/exe/content/ xpcnativewrappers=yes

  1. The exe.js file, which is loaded by the exe.xul file finds the PyXPCOM mainpage component inside of the exeApp component, and passes it a refernece to the DOM of the document. Something like this: exeApp.mainPage.render(document). This will fill in the Node tree, the IDevice pane and set the window.caption 3.1. We may not need to use this render/process method; we may be able

to use a callMethod system, similar to what nevow already does.

  1. Then the exe.js find the authoringPane component inside of main page and pass it the authoring pane document. Something like this: exeApp.mainPage.authoringPane.render(document.getElementById("authoringPane").contentDocument 4.1. A similar process is used for properties page. However as the

properties page is already XUL and already live, we don't need to be restricted to the render/post system; we can use the current callMethod used by nevow. (The same may go for mainpage.xul).

How to build PyXPCOM for firefox 2

The PyXPCOM that comes with firefox 2.0.0.1 could be built using external include files, but the 2.0.0.2 needs a lot of the firefox source tree. These instructions are for the firefox 2.0.0.2 PyXPCOM build. Once the DLLs are built you should be able to run them against a system supplied firefox.

wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.2/source/firefox-2.0.0.2-source.tar.bz2 
tar xjf firefox-2.0.0.2-source.tar.bz2
cd mozilla
cat > .mozconfig
#mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-pyxpcom-build
. $topsrcdir/browser/config/mozconfig
ac_add_options --enable-extensions=default,python/xpcom

(ctrl+d)

make -f client.mk

Here we've used a very simple the .mozconfig file. If these simple settings don't work, try copying the settings from your system's firefox:

  1. In your system firefox navigate to: about:buildconfig
  2. Copy all the options under Configure Arguments into your .mozconfig file
  3. Edit the file and put: ac_add_options before each {{--}}
  4. make -f client.mk clean
  5. make -f client.mk

If there are any other build probs, info can be found here.

Installing in your system firefox

From the mozilla directory, as root:

# Set MOZ_DIR to whatever your mozilla dir is. This dir should be the one with the components subdir
MOZ_DIR=/usr/lib/mozilla-firefox
cp obj-pyxpcom-build/dist/bin/components/*py* $MOZ_DIR/components
# This xpcom dir is a python directory, it could be copied to /usr/lib/python2.5/ or xpcom
cp obj-pyxpcom-build/dist/bin/xpcom $MOZ_DIR/xpcom