JS-Python Communication using PyXPCom

Tomeu Vizoso tomeu at tomeuvizoso.net
Sun Mar 23 06:03:32 EDT 2008


Hi,

thought I already had suggested this a long time ago, but anyway:

- Create a XPCOM service in JS that exposes the spreadsheet
functionality implemented in JS.

- Create another XPCOM service in python that exposes the needed Sugar
functionality.

Shouldn't this allow you to integrate SocialCalc in any way you wish?
Creating these two components shouldn't be too hard. Please feel free
to ask in this mailing list any doubts you have.

Example of JS service:
http://dev.laptop.org/git?p=sugar;a=tree;f=browser/components/sessionstore;h=8f894b116ad745b0f7bc7c89e4787c89e60a9eb2;hb=309ddec8b769af42f577229bc5e3278c0328f1c4

Good luck,

Tomeu

2008/3/22 Manusheel Gupta <manu at laptop.org>:
> FYI
>
> Regards,
> Manu
>
>
> Manusheel Gupta
> Technical Consultant and Adviser
> One Laptop Per Child Inc.
> http://laptop.org
>
>
>
> ---------- Forwarded message ----------
> From: Luke Closs <lukecloss at gmail.com>
> Date: Fri, Mar 21, 2008 at 1:27 AM
>  Subject: Re: hello
> To: Joshua McKenty <jmckenty at gmail.com>, manu at laptop.org
>
>
> On Thu, Mar 20, 2008 at 10:27 AM, Joshua McKenty <jmckenty at gmail.com> wrote:
>
>
> > Luke,
> >
> >
> > Good to hear from you. (I thought it was OLPC laptop, though).
> >
> >
> > What questions have you got?
> >
> >
> > Joshua
>
> Hey Joshua,
>
> I've cc'd Manu Gupta, who is collaborating with me on this OLPC spreadsheet
> activity.
>
> (OLPC is the non-profit organization, XO is the laptop)
>
>  So I'm kinda at a standstill on this project b/c I'm not sure how to
> proceed technically - so I'm hoping you can help here, based on the
> discussion we had at Northern Voice.
>
> As I mentioned in person, I've got events going back and forth between
> python and javascript via pyXPCom.  This should work okay for most of the
> interactions I need to do, except one.  (I'm not tied to the EventObserver,
> but it seems to get the job done - I'd consider using another mechanism
> too).  The one thing where events will not work is when we need to save the
> spreadsheet.  For instance, the user may quit the program, in which case my
> python method write_file() will be called, and I need to (synchronously)
> tell javascript to calculate the string that should be saved and give it
> back, so I can write it to disk.  I don't think an event passing model
> (asynch) would work in this case.
>
> I've looked into how Javascript could define a XPCom interface, that the
> python code could call, but this seems to require additional steps for
> compiling that interface, and I'm not sure how I would end up packaging
> those into the sugar app.
>
> So basically, I need your help to figure out how my python code can make a
> synchronous method call to javascript to calculate and return stuff.
>
> Thoughts?
>
> Cheers,
> Luke
>
>
> _______________________________________________
>  Devel mailing list
>  Devel at lists.laptop.org
>  http://lists.laptop.org/listinfo/devel
>
>


More information about the Devel mailing list