On Jan 18, 2:13 am, Massimo Di Pierro <[email protected]>
wrote:
> this is not possible because includes and extends must be resolved
> before compilation, not at runtime
I have been thinking about this for a while. In principle, it should
be possible to have the compiled version be able to read, at runtime,
the script to be included. It really just means that the code works a
little differently, e.g. a regular python app that either has the name
of a data file hard-coded into source which then ends up inside the
pyc, compared to a slightly modified python app that has code to read
the name of the data file as a run-time input, in which case the name
of the data file is not included statically inside the pyc.
Since the code is executed, not imported, one approach here might be
to pre-configure a structure into the locals() dict in the environment
in which the code is 'exec'ed, and this structure contains the names
of the views to be included, and key-value lookup is performed for
each {{include x}} directive.
I imagine you have considered similar kinds of schemes before.