Mercurial > genshi > genshi-test
comparison markup/template.py @ 192:cda3bdfc19ed
Expression evaluation now differentiates between undefined variables and variables that are defined but set to `None`.
author | cmlenz |
---|---|
date | Wed, 23 Aug 2006 17:49:14 +0000 |
parents | 929ef2913b87 |
children | 76129a79458d |
comparison
equal
deleted
inserted
replaced
191:929ef2913b87 | 192:cda3bdfc19ed |
---|---|
109 | 109 |
110 def __setitem__(self, key, value): | 110 def __setitem__(self, key, value): |
111 """Set a variable in the current scope.""" | 111 """Set a variable in the current scope.""" |
112 self.frames[0][key] = value | 112 self.frames[0][key] = value |
113 | 113 |
114 def get(self, key): | 114 def get(self, key, default=None): |
115 """Get a variable's value, starting at the current scope and going | 115 """Get a variable's value, starting at the current scope and going |
116 upward. | 116 upward. |
117 """ | 117 """ |
118 for frame in self.frames: | 118 for frame in self.frames: |
119 if key in frame: | 119 if key in frame: |
120 return frame[key] | 120 return frame[key] |
121 return default | |
121 __getitem__ = get | 122 __getitem__ = get |
122 | 123 |
123 def push(self, data): | 124 def push(self, data): |
124 """Push a new scope on the stack.""" | 125 """Push a new scope on the stack.""" |
125 | 126 |