On Tue, Jul 21, 2009 at 9:07 PM, Ondrej Certik<ond...@certik.cz> wrote:
> On Tue, Jul 21, 2009 at 9:03 PM, Ondrej Certik<ond...@certik.cz> wrote:
>> Hi,
>>
>> here is an early preview of the pyjamas version:
>>
>> http://2.latest.pythonnb.appspot.com/
>>
>> So far my experience is:
>>
>> * it doesn't work in IE8 (that's a showstopper)
>> * it's fast enough
>> * implementing the cursor positions and resizing was a piece of cake
>> (I was very impressed)
>> * learning the whole framework took me some time, one has to read sources a 
>> lot
>> * if it doesn't work, it's a bit difficult to debug (because it's not
>> just javascript, I need to figure out where I made the mistake in the
>> python code), I basically use git a lot and always do a small change
>> and test, small change and test. If it fails, I break my changes in
>> half and test, etc.
>>
>> Essentially, pyjamas provide a complete DOM access (just like jQuery),
>> but in Python, and then builds its own widgets on top of it.
>>
>> I am now learning how to do AJAX with it. So far only the cursor
>> movement and cells work (the focus is not yet shown by a blue line,
>> I'll do that later). Try this:
>>
>> def f(x):
>> <hit TAB couple times>
>>
>> and then hit <backspace>, you will see that it deletes 4 spaces, but
>> in a clever way, e.g. if you are at a position 7, it goes to 4 first
>> and then to 0. This is how my vim is setup for python editing and I
>> like it a lot.
>>
>> Let me know if it works in your browser so far. I only tested firefox
>> 3.5, that works fine. IE8 doesn't load the javascript, e.g. you will
>> see no textbox. Also, in Firefox I get frequent error messages
>> (printed in the actual HTML):
>>
>> "
>> JavaScript Error: Permission denied to get property
>> HTMLDivElement.parentNode at line number 9254. Please inform
>> webmaster.
>> "
>>
>> It's a bug in pyjamas.
>
> Also cell joining is not yet implemented. But it works in the Chrome
> browser, so at least something.

I implemented the AJAX thing as well, here is a working example (sort of):

http://3.latest.pythonnb.appspot.com/media_files/output/index.html

Besides what I wrote above, there is some problem with CSS styles,
which shows up when you evaluate some cell and see the output, the
"insert new cell blue thin line" is misplaced.

I implemented it in the "pyjamas" branch in my repository (link is on
the webpage), so there are some leftovers (like the jQuery.js library,
which is *not* needed anymore, etc.). The django backend didn't change
at all and now the whole notebook doesn't contain a single line of
javascript (everything is pure python). I think that itself is pretty
impressive. Here is the file, that gets translated:

http://github.com/certik/notebook/blob/001b4ddf444b480822adf9216419afa1adaf4818/media/index.py

In terms of lines of code, it's about the same as my previous version
in javascript:

http://github.com/certik/notebook/blob/ca4e6a90a3f0c10c78c8c99d4d55055ba5019c28/templates/index.html

But there are still some things missing (e.g. joining and deleting the
cells). The python code should be refactored first though, there
should be a class Cell, that should have references to it's children,
like the input/output cells etc. and this class should now how to turn
on/off the output cell etc. Currently I am using the DOM directly in a
bit hackish way, this should be polished. Essentially I was fighting
pyjamas to access the elements in the DOM, for example jQuery's
analogs of insert before and after are not available (resp. it's
tricky).

Nevertheless, overall, I like the pyjamas approach and the above
things can be fixed. Also now there is a nice possibility to mock up
the controls and run regular python unittests on the whole thing.
That's a big plus.

The remaining big problem is the IE8 support and the errors that
sometimes popup in firefox. I reported it here:

http://groups.google.com/group/pyjamas-dev/browse_thread/thread/f170c3709c7f12ed

and I was told I am pretty much on my own with IE8. So that's very
disappointing of course, but maybe the fix is easy. If it is not, then
that's a big problem.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to