> I really wanted to use with statements in the .ptl files. Since > "from __future__ import with_statement" didn't work, I did this: I think this patch does the right thing. I'll test it for a while. If other people have success or failure, please shoot me an email. Neil === modified file 'quixote/ptl/ptl_compile.py' --- quixote/ptl/ptl_compile.py 2006-08-07 21:44:13 +0000 +++ quixote/ptl/ptl_compile.py 2007-10-01 22:53:14 +0000 @@ -59,12 +59,20 @@ 'quixote.html', [('TemplateIO', '_q_TemplateIO'), ('htmltext', '_q_htmltext')]) vars_imp = ast.From("__builtin__", [("vars", "_q_vars")]) - stmts = [ vars_imp, html_imp ] + ptl_imports = [ vars_imp, html_imp ] + stmts = [] for node in nodelist: if node[0] != token.ENDMARKER and node[0] != token.NEWLINE: self.com_append_stmt(stmts, node) - + # count __future__ statements + i = 0 + for stmt in stmts: + if isinstance(stmt, ast.From) and stmt.modname == '__future__': + i += 1 + else: + break + stmts[i:i] = ptl_imports return ast.Module(doc, ast.Stmt(stmts)) def funcdef(self, nodelist):