I am currently using webpy , which has the same limitation, its template system cannot access the parser module (blocked) and cannot write to the file system in Google App Engine, so you need to precompile the templates.
I solved this unpleasant problem with the help of a Python script, which, every time a file with a given directory is changed, starts a preliminary compilation of this file.
I am on OSX and I use FSEvents , but I believe that you can find other solutions / libraries on any other platform ( incron on Linux, FileSystemWatcher on Windows):
from fsevents import Observer from fsevents import Stream from datetime import datetime import subprocess import os import time PROJECT_PATH = '/Users/.../Project/GoogleAppEngine/stackprinter/' TEMPLATE_COMPILE_PATH = os.path.join(PROJECT_PATH,'web','template.py') VIEWS_PATH = os.path.join(PROJECT_PATH,'app','views') def callback(event): if event.name.endswith('.html'): subprocess.Popen('python2.5 %s %s %s' % ( TEMPLATE_COMPILE_PATH ,'--compile', VIEWS_PATH) , shell=True) print '%s - %s compiled!' % (datetime.now(), event.name.split('/')[-1]) observer = Observer() observer.start() stream = Stream(callback, VIEWS_PATH, file_events=True) observer.schedule(stream) while not observer.isAlive(): time.sleep(0.1)
source share