[Tutor] Cheetah

Mike Hansen mhansen at cso.atmel.com
Wed Apr 26 21:12:15 CEST 2006


I'm having a little trouble populating a cheetah template. I thought I'd ask
here first before checking the cheetah mailing list or c.l.p.

I have a simple template

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
    <title>This is a test</title>
</head>
<body>
    <h1>$title<h1>
                
#for $item in $items
<p>category: $item.category</p>
<p>name: $item.name </p>
<p>price: $item.price</p>
#end for
</body>
</html>

That I compiled using cheetah.

Here's the python code that uses it:

#!/usr/bin/env python

import testform
import cgitb; cgitb.enable()

class ReqItem(object):
    def __init__(self, category, name, price):
        self.category = category
        self.name = name
        self.price = price

t = testform.testform()
t.title = "this and that"

items = []

category = "little stuff"
name = "hotwheel"
price = "2"

item = ReqItem(category, name, price)

items.append(item)

category = "big stuff"
name = "monster truck"
price = "30000"

item = ReqItem(category, name, price)

items.append(item)

t.items = items

print "Content-Type: text/html\n\n"
print str(t)


However, I get the following error:

Traceback (most recent call last):
  File "./testit.py", line 36, in ?
    print str(t)
  File "testform.py", line 100, in respond
    __v = VFFSL(SL,"item.category",True)
NotFound: cannot find 'category' while searching for 'item.category'

Does anyone know what I'm doing wrong?



More information about the Tutor mailing list