The Artima Developer Community
Sponsored Link

Python Buzz Forum
My First Ajax App

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
My First Ajax App Posted: Jun 13, 2005 1:34 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: My First Ajax App
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

Well, it took a while, but I finally finished my first experiment with Ajax (aka Asynchronous Javascript and XML; i.e., DHTML revisited). It actually doesn't use XML, but I guess it uses XMLHttpRequest, so that's good enough.

Sadly I cannot demo it for you all, but you can run it on your own with Paste; it's at http://svn.pythonpaste.org/Paste/trunk/examples/console -- it gives you an interface similar to the interactive interpreter in Python (obviously not secure for the public web!). When you enter a command, it sends it to the server (as a URL-encode POST request at the moment), and the server returns any output (including the repr of any expression, the way the interactive interpreter does). I used code from doctest as a model for evalcontext, which implements the actual interpreter part. Everything gets interpreted in the server process, so potentially it's a debugging tool. I can imagine lots of ways to improve it for debugging -- things like HTML object inspectors -- but this is just a minimal experiment at this point. Or other similar tools, like something similar to tail that shows an ongoing list of log messages. (Paste first needs a logging system, though -- based on logging of course, but made more convenient)

In theory you could even hook up pdb to this kind of system and debug exceptions. That would be neat. Not that I actually use pdb that often, but I feel like I should. Right now post-mortem debugging is generally more useful to me, and with good post-mortem debugging the interactive work isn't as hard. I still need to add cgitb-like capturing of local variables. But I can imagine an entirely different error middleware (different than this) that implements the debugger. Parallel development of these things is part of what I hope to see from WSGI.

Thinking about it, it doesn't even seem that hard. You catch an execption. You get sys.exc_info(), which contains all the frames from the exception, and thus contains all the local variables. You show a traceback. You have something like this interactive console, but you also let the user select a frame from the traceback, so that their statements will be executed in that scope. And there you have a pretty neat little debugging environment. Fun. But... must... not... get... distracted...

I used Javascript O Lait for the Javascript. I tried using JSON-RPC (via ServerProxy and JSONComponent), but it was too slow for some reason. I'll figure that why later. So in the end I just used urllib, which is a fairly thin wrapper around XMLHttpRequest. I've looked at Dojo, which seems simple but doesn't seem to have any useable documentation and the download is huge and confusing. I looked at Sarissa, but it's mostly about XML, and XML is the least interesting part of Ajax to me. I looked at Sajax, but it's a little too clever with the server-side stuff for me. I want to develop the server-side integration myself, in whatever way makes best sense for the framework. But it probably deserves a bit more attention; it's the next closest in scope to what I'm interested in.

Dang, that's a lot of links. Well, there's my link dump for ya'.

Read: My First Ajax App

Topic: Python on Mac OS X (WWDC 2005, Session 613) Previous Topic   Next Topic Topic: Python on Mac OS X (x86)…

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use