| 196 | |
| 197 | |
| 198 | def get_jinja_locals(real_locals): |
| 199 | ctx = real_locals.get('context') |
| 200 | if ctx: |
| 201 | locals = ctx.get_all().copy() |
| 202 | else: |
| 203 | locals = {} |
| 204 | |
| 205 | local_overrides = {} |
| 206 | |
| 207 | for name, value in iteritems(real_locals): |
| 208 | if not name.startswith('l_') or value is missing: |
| 209 | continue |
| 210 | try: |
| 211 | _, depth, name = name.split('_', 2) |
| 212 | depth = int(depth) |
| 213 | except ValueError: |
| 214 | continue |
| 215 | cur_depth = local_overrides.get(name, (-1,))[0] |
| 216 | if cur_depth < depth: |
| 217 | local_overrides[name] = (depth, value) |
| 218 | |
| 219 | for name, (_, value) in iteritems(local_overrides): |
| 220 | if value is missing: |
| 221 | locals.pop(name, None) |
| 222 | else: |
| 223 | locals[name] = value |
| 224 | |
| 225 | return locals |
| 226 | |
| 227 | |
| 228 | def fake_exc_info(exc_info, filename, lineno): |