Posts for the month of March 2009

Nagare installation on Mac OS X (Leopard)

As Mac OS X is a unix based system, the Linux section of NagareInstallation#linux-installation applies, but a few tweaks are needed to setup a fully working nagare environment.

We'll need the following external tools:

Install Xcode

Xcode should be available from your Applications Install DVD or can be downloaded from here.

Install MacPorts

Install instructions can be found here.

Install Stackless

Here we have to give some specific options to configure:

cd /tmp
tar jxvf stackless-252-export.tar.bz2
cd stackless-2.5.2*
./configure --enable-stacklessfewerregisters --enable-universalsdk --prefix=<STACKLESS_HOME>
make all
sudo make install

--enable-stacklessfewerregisters and --enable-universalsdk are the key options here. Also note how Stackless Python is installed in its own <STACKLESS_HOME> directory, in order not to override the Python system.

Install libxml2 and libxslt

As the libxml2 version given with Xcode prevents lxml from installing, we'll use MacPorts to install the right one:

sudo port install libxslt

Finish nagare installation

From now on, you can follow the vanilla install guide, starting with section 2.

Dynamic content from actions

In the previous post (blog:dynamic_images) we saw how to use the action() method of the img tag to put dynamic images in a view.

Let's see now how to serve any other dynamic content by raising a HTTPOk exception:

import time
from webob.exc import HTTPOk
class MyApp(object):
    def get_text(self, *args):
        data = time.asctime()
        e = HTTPOk()
        e.body = data
        e.content_type = 'text/plain'
        raise e
from nagare import presentation
def render(self, h, *args):
    return h.a('Click me').action(self.get_text)

Nagare catches such webob.exc exceptions; as they inherit from webob.Response they are immediatly returned in the WSGI pipe.