[Welcome] [TitleIndex] [WordIndex

Quixote and SimpleTAL Integration

Note: this solution is written for Quixote 1.x. The basic idea should still work for Quixote 2 however.

Here's quixote_tal.py a module that demonstrates using SimpleTAL with Quixote.

It has two interesting features:

<p tal:content="root/package/obj/method">results of calling method</p>

<p tal:content="self/method">results of calling instance method</p>

You can also access normal quixote stuff like the request, form, cookies, session, user, etc.

Other examples of using SimpleTAL:


To use quixote_tal simply create templates in your quixote application. Here's an example:

from quixote_tal import Template, TemplateMethod
from new import instancemethod

_q_exports=['page', 'bill']

# creates a stand alone web page

class Person:
    Example class that uses a template to display instances

    def __init__(self, name):



Here's an example of what the person.html template might contain:

  <p>My name is <b tal:replace="self/name">name</b></p>

Here's an example of a stand alone webpage such as page.html:


  <p>Quixote root name <b tal:content="python:root.__name__">name</b></p>

  <p>URL <b tal:content="request/get_url">url</b></p>

  <p>Form variables</p>

    <li tal:repeat="name request/form/keys"

  <p>bill's name <b tal:replace="root/bill/name">name</b></p>


Note: in the example above a python expression is required to access root.name since it isn't a web accessible object. Python expressions aren't security restricted in simpletal like they are in ZPT.



2010-09-22 22:14