Home
Donovan Preston's Journal
 
[Most Recent Entries] [Calendar View] [Friends]

Below are the 12 most recent journal entries recorded in Donovan Preston's LiveJournal:

    Sunday, June 13th, 2004
    11:38 am
    Artistic Hacks
    On memorial day weekend, when I was driving back up to Paradise, I drank a Red Bull to stay awake. Having been off caffeine for a while and *never* drinking Red Bull, it got me thinking.

    Arianna and I have been talking about doing a web toy for a while which uses Flash, mixes interactivity with multiple user shared spaces, and lets the user affect the animations and the soundtrack playing in the space. I could have at any point written a one-off chunk of client and server code for implementing this space, but in the car I had a better idea.

    nevow.canvas is the result, and it is an outgrowth of the LivePage philosophy of web application interaction I have been attempting to get off the ground for a few years now. nevow.canvas is a module which has a simple function, canvas(height, width, onload). The result of this function call is an embedded Flash movie in your HTML page of the given height and width. The movie itself never changes (that is to say I am not doing .swf file generation on the server, here); instead, the movie opens a socket connection to the server and the server holds it open until you say to close it.

    Once the Flash movie connects a socket to the server, nevow calls your onload function with a CanvasSocket object. The CanvasSocket object has many very convenient APIs for drawing in the movie. pen, line, fill, curve, gradient, image, and text APIs are all available for you to draw with.

    Since the server holds the socket connection open until you say you are done with it, you are free to perform animations, draw graphs in response to server-side information becoming available, etc. I haven't yet completed mouse and keyboard event handling, but plan to in the near future.

    I have put up a simple demo application which draws some random shapes at http://soundtractor.com:8080/, and the source is available as nevow/canvas.py and nevow/Canvas.as. The demo application is in examples/canvas.tac.

    Hope you enjoy the canvas, and I look forward to performing lots of artistic hacks with it!

    Current Mood: pleased
    Thursday, May 6th, 2004
    11:07 pm
    Warning: Before you update Nevow. Major merge completed!
    Before you update Nevow to the latest version of trunk, make sure you have a few minutes to work around any potential roughness. The development which was happening on the freeform-patterened branch was merged tonight. All in all, it seems to be fairly backwards compatible.

    *You should clean out your old pyc files*. Otherwise, nevow will have problems starting up because it will import the old nevow/formless.pyc module instead of the new top-level formless package.

    If you were doing anything fancy with formless, such as subclassing Configurable or implementing your own Typed subclass, you will need to make some minor tweaks. The Configurable baseclass is now in the formless.configurable module, and the Typed.coerce signature is now coerce(self, data, configurable) instead of coerce(self, data).

    This merge almost completely rewrites the formless code from the ground up. The code is much more straightforward and better tested. formless.webform.renderForms() can now be provided with pattern nodes to influence the rendering of the forms. The structure and layout of the forms can be completely controlled.

    This merge also significantly simplifies how Nevow goes about the rendering process, reducing the previous flatten, strflatten _flatten, render, and other incomprehensible driver functions with a simpler set of driver functions, contained in the nevow.flat package. You probably won't care about this unless you would like to try to read the nevow code and understand how it works.

    If you encounter any other problems with this update, please let us know on the mailing list or on the #twisted.web channel. Thanks!

    Current Mood: amused
    Friday, March 12th, 2004
    3:15 pm
    Nevow CVS, PyCon approacheth
    I know things have been quiet around here lately, but things have been very busy indeed with Nevow and Quotient.

    Thought I might as well write an update about the progress of Nevow. First, there is a new wiki URL:

    http://divmod.org/users/wiki.twistd/nevow/moin.cgi

    And there is a new, non-quotient dependent CVS repository:

    cvs -d:pserver:anon@divmod.org:/cvs co Nevow

    Most of the examples on this LiveJournal are slightly out of date. Instead, you should take a gander at the examples in Nevow/examples and the documentation in Nevow/doc. More docs will be written soon, before PyCon, and we plan to have a release out around the time of PyCon.

    Current Mood: amused
    Current Music: Hawkind-Donna Summer-To All Methods Which Calculate Power
    Wednesday, February 11th, 2004
    11:18 pm
    Oh by the way, have you met my evil twin?
    I have decided to write more on my other blog:

    http://ulaluma.com/pyx/

    So if you are interested in reading about my reimplementation of LivePage in Nevow, go read my new entry there :-)

    Current Mood: amused
    Current Music: Dab-John Oswald-Plunderphonics 69/96 Disc 1 Tunes
    Friday, January 16th, 2004
    9:46 am
    Nevow Wiki in operation
    We now have a nevow wiki in place and operational. Please visit it, comment and contribute!

    http://divmod.org/users/dp.twistd/wiki/

    Current Mood: accomplished
    Current Music: Trancentral Lost in My Mind-The KLF-KLF - Chill Out
    Wednesday, January 7th, 2004
    9:17 pm
    Updated examples
    I did minor tweaks to all of the examples listed on this page. Minor style cleanups, and one notable bugfix (formpost.tac had a subclass of Renderer that didn't declare it implemented the same interfaces as Renderer). Nevow is getting some architectural polish, mostly in the appserver module, in areas related to URL to object lookup and session handling. Expect mild bumpiness if you follow CVS head, to be ironed out over the next few days.

    Current Mood: awake
    Current Music: Squarepusher Theme-Squarepusher-Feed Me Weird Things
    Thursday, December 18th, 2003
    12:22 pm
    Another example
    It irritated me that the original disktemplates.tac example required that the HTML template being applied to the list had to be repeated in the template. In woven, it was possible to read another file off disk and "insert" it into a node in the context of a larger template. I decided it would be good to add this functionality to nevow.

    So now it is possible to both use an HTMLRenderer to render an entire page, or return an HTMLRenderer from a render_* method within the context of another page. When an HTMLRenderer is used inside of a larger page, the key node "content" is the node that is actually inserted. This is so you can use the same instance to render both a full HTML page and an HTML fragment.

    http://soundfarmer.com/content/code/disktemplates2/

    Current Music: Brace Yourself (Remix)-µ-Ziq-Brace Yourself
    Wednesday, December 17th, 2003
    3:23 pm
    How to use a .tac file
    In case anyone isn't aware, a .tac file (twisted application configuration) is simply a python file which defines an "application" variable. To run a tac file, you use twistd and pass it the --python flag (or -y):

    twistd -noy foo.tac

    The other options I use are n, no daemonize (run without becoming daemonized, so you see the output in the terminal and can terminate the process with control-c) and o, no save (don't persist an application object at server shutdown).

    Current Music: Drunken Mozart Style-Doormouse
    1:51 pm
    Nevow example code
    I have been writing a lot of small samples of nevow applications for people lately. People will ask questions on #twisted.web (on irc.freenode.net, come join us) and on the twisted-web mailing list (http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web) and I find the best way to answer the question is to come up with a small, working example. Without further ado, the examples:

    A simple example which shows you how to get off the ground, use the stan HTML expression syntax, and insert dynamic content into a page:

    http://soundfarmer.com/content/code/simple.tac

    When looking at any of these examples, remind yourself that if you don't like the stan HTML expression syntax, you can always use disk-based HTML templates instead:

    http://soundfarmer.com/content/code/disktemplates.tac
    http://soundfarmer.com/content/code/Hello.html

    An example of how you might use a traditional string-concatenation or string-substitution approach to building HTML, and then how you might port it over to use the stan syntax:

    http://soundfarmer.com/content/code/nestedmenus.tac

    Progressively more complicated examples of how you can use formless to describe the types your object's methods take and the types your object's properties are, and freeform to render a form which will automatically call your methods or set your properties once the input passes validation:

    This example exposes a property of an instance to the user:
    http://soundfarmer.com/content/code/formpost.tac
    This example exposes a method to the user:
    http://soundfarmer.com/content/code/formpost2.tac
    This example exposes a list of configurables to the user:
    http://soundfarmer.com/content/code/formpost3.tac
    This example shows how we can use a grouping to group validators so that all forms are submitted at once, and all validators must pass before any configuration occurs:
    http://soundfarmer.com/content/code/formpost4.tac
    This example shows how we can add action methods to a list, which will render buttons and checkboxes and call our action method with a list of the checked items:
    http://soundfarmer.com/content/code/formpost5.tac

    A more complicated example shows how we can structure a dynamic URL tree to expose a simple "database" over the web, and allow users to add items to the database, as well as edit existing items:

    http://soundfarmer.com/content/code/db.tac

    Finally, an example of how you can guard your nevow site by implementing some of the twisted.cred interfaces and wrapping some guard objects around your resource:

    http://soundfarmer.com/content/code/guarded.tac

    I hope these examples are useful. However, keep in mind that in the real world, you should not define your classes inside of a .tac file. Only the application construction and port-binding code should go in the .tac; move your class definitions into a module, please.
    Tuesday, December 16th, 2003
    9:05 am
    Nevow lecture series part 2
    Last night, Nafai wanted a tutorial on how to start using Nevow from the ground up, so I ended up giving another short "lecture" about Nevow. This one is a lot easier to understand for beginners, because it focuses on how to use it, not how it is implemented. Check it out here: Lecture 2

    Current Mood: relaxed
    Current Music: Nanook Rubs It - Apostrophe - Frank Zappa
    Tuesday, November 25th, 2003
    11:59 am
    Nevow Lecture Series Part 1
    Last night on IRC, there were quite a few people who were interested in hearing about the mechanics of Nevow. So I ended up talking at length in detail about how nevow works. A transcript of the conversation can be found here:

    Nevow Lecture 1

    Current Mood: busy
    Current Music: MOBO MOGA-Orange Lounge-Dance Dance Revolution 8th Mix -Extreme-
    Friday, October 17th, 2003
    5:26 am
    A new era dawns
    Amir was kind enough to invite me to LiveJournal, where the employees of Divmod are going to try an experiment with communication. At this point, our main purpose is to use the blogging tools that exist and attempt to discover the essence of the medium.

    I have been blogging for a while -- at http://www.ulaluma.com/pyx/ -- but haven't updated it very regularly. When I post there, it's mostly technical details about using Python on the Mac. This blog will be more focused on what we do at Divmod, including the techniques I use in the Quotient web ui, thoughts about where we want to go with our system, and tips for using Twisted, specifically twisted.web and twisted.web.woven.

    Right now my main focus in Quotient is the webmail interface. The current release, 0.6.5, is pretty capable as a webmail platform, but our backend is currently still undergoing heavy revision. At the moment, Quotient's persistence layer is being rewritten to use bsddb throughout, using the module storeq. I'm pretty excited about this development (although I am not doing it, it's being done by glyph) because it means we will be able to focus on the higher level tasks of allowing the user to store and organize a large amount of information in ways that make sense to them without worrying as much about performance or stability.

    Another big innovation in Quotient that I am excited about is quotient.formless, an evolution of glyph's ideas in twisted.python.formmethod, and quotient.web.webform, an evolution of twisted.web.woven.form. The current implementation is based on the woven architecture as it is in twisted, which while it has proven very capable, has also proven to be fairly difficult to work with. Formless is a way to describe object and method schemas, and webform is a way to automatically render those forms to the web, and gather form post data, validate it, cast it to the types described by the schema, and then either set properties of objects or call methods on objects. Automatically.

    One of the most difficult parts of formless/webform is allowing the user to specify an existing Python object reference to pass to a Python method. One of the techniques I am toying with implementing in Quotient is an "Object Shopping Cart", which I call the shelf (in homage to NeXTStep). Users can drag object references to the Shelf to carry them around across multiple page renders. Here is a screenshot of an actual, working implementation of the shelf that is in Quotient CVS, but currently turned off:

    http://soundfarmer.com/pictures/screenshots/Formless.png

    Another thing that I am currently working on in my spare time after work but will eventually use in Quotient is nevow, an exploratory rewrite of Woven which takes all the best concepts from Woven and reduces them to an implementation that's around 500 lines. I initially said I could make the entire implementation 500 lines, but if I'm going to support Deferreds and any sort of current Woven backwards compatibility, I'm going to break through that. But I'll write more about nevow later, when I am closer to a usable implementation.

    Current Mood: peaceful
    Current Music: Silence
About LiveJournal.com