not that I recommend this but you can do

def index():
    execfile(os.path.join(request.folder,'models','mymodel.py'))
    ...
    return locals()

The execfile can be outside.

I do not think it is a good idea because it would not take advantage
of pyc caching, bytecode compilation would break and because it is
better to define code to be executed on demand in modules (not
models), import them and call functions that do what you need
conditionally.


On May 1, 7:04 pm, Bruno Rocha <rochacbr...@gmail.com> wrote:
> great improvement, I am testing right now.
>
> A question that will raise soon is: How do I execute a model on demand? if I
> am in /default/foo and want an object defined in /default/bar, how do I
> force this model file to run?
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]
>
> On Sun, May 1, 2011 at 7:30 PM, Massimo Di Pierro <
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > In trunk we have - experimentally - conditional web2py models
>
> > 1) models/anything.py (for all controllers)
> > 2) models/<c>/anything.py (only forfunction in controller <c>)
> > 3) models/<c>/<f>/anything.py (only for function f in controller <c>)
>
> > when you canhttp://..../<c>/<f>
> > all models 1 are executed alphabetically, the 2 alphabetically then 3
> > alphabetically.
>
> > Please help us test that:
> > 1) it works
> > 2) it works if you bytecode compile the app
> > 3) it does not apps that were bytecode compiled with a previous web2py
> > version
>
> > This should provide a major speedup for those apps with lots of tables
> > like ShanaEden.
>
> > Massimo

Reply via email to