summaryrefslogtreecommitdiff
path: root/docs/users_guide_2_src/eg_4.py
blob: 8fab6574b8f538e99ab549804d75c59208882a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from Cheetah.Template import Template
from Cheetah import NameMapper

#Error. Cheetah cannot find 'x' because
#it is not dictionary key or instance member:


class X:
    pass

x = X()
x.value3 = 3
    
tmpl = "$x.value3"
NS = [x]
t = Template.compile(source=tmpl)(namespaces=NS)
try:
    t.respond()  #Here substitution is attempted
except NameMapper.NotFound, e: 
    print 'NameMapper.NotFound: %s' % e
    #NameMapper.NotFound: cannot find 'x'