Chris McDonough wrote: > On 5/9/09 8:50 AM, Malthe Borch wrote: >> As a general improvement (in terms of clarity) and as part of the >> efforts of getting Chameleon working on GAE, I've begun reworking the >> compilation stage. >> >> If not explicitly disabled (using ``CHAMELEON_CACHE=0``), template >> files (ending in .pt) will be compiled with the result written to a >> Python-module with the same filename (ending in .pt.py); Python will >> of course attempt to write a byte-code compilation (ending in >> .pt.pyc), which will guarantee good performance when restarting the >> system. >> >> Then, >> >> On template instantiation: >> >> 1) If the ``CHAMELEON_EAGER`` flag is enabled, parse template source >> immediately. >> 2) Load the template source module. >> 3) If the ``CHAMELEON_STATIC`` flag is enabled, compile into >> one-method-fits-all-arguments render methods for main template and >> each available macro (if required). >> >> On render: >> >> 4) If the ``CHAMELEON_STATIC`` flag is enabled, collapse >> keyword-arguments into dynamic context (econtext). >> >> On compilation: >> >> 5) If the "render call signature" (keyword arguments and macro name) >> matches an already compiled render-method, return it. >> >> Else: >> >> 6) Compile template (to source string). >> 7) Append to template source module. >> 8) Reload template source module and return render-method. > > I've lost track of what a lot of this means (particularly wrt > CHAMELEON_STATIC) > but the stuff I do understand sounds pretty good to me. > > At a higher level, let me try to repeat the use case here and tell me if I > have > it right: > > - On template instantiation (at least in eager mode and unless > CHAMELEON_CACHE=0), a .py file will be written next to the > template file being instantiated. > > - The Chameleon code that actually performs rendering will > try to find the .py file via some importy sort of thing. > > - Python will write the .pyc file. > > - When we want to deploy to GAE or other platforms without > instantiation/compilation support, we'll just check in > the .py files (or maybe even the .pyc files) and > push them up. The instantiation code won't ever need > to do the compilation step.
It'd be nice if there was a way to name the files that meant people won't accidentally commit a bunch of "compiled" .py files that may then end up conflicting later. Already, people are checking in the .cache files, but at least then you can do an svn ignore filter on *.cache. You can't ignore *.py. :) I guess you can ignore *.pt.py, but I suspect people won't understand this. We can't go straight to .pyc? Won't GAE execute .pyc files? Also see the note about the _ast module earlier today. Martin -- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book _______________________________________________ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev