On Jan 5, 7:21 pm, s...@pobox.com wrote:
>     Thadeus> Web2py models/controllers/views are EXECUTED not IMPORTED.
>
> Sorry, I've been using Python for 15 years but haven't seen this distinction
> before.  What do you mean "executed not imported"?  If I edit some file does
> web2py notice the change in timestamp then execfile(...) it or reload(...)
> it?

No.
web2py does not do "import yourcontroller"
web2py does something like "execfile(yourcontroller) in environment"
on every request.
There are some optimizations having to do with byte compilation.
Because it executes the code on every request there no need to ever
checks the timestamp.

> What about classes defined in those files?
> Are existing instances somehow brought up-to-date?

For instances created in models and controller, a new instance is
created on every request. If your models and controllers import
modules and those modules create instances, those are created only the
first time the module is imported, once. This gives you a choice.

> What about files imported in a view?  (I
> noticed somewhere along the way that the syntax to import a file in a view
> is pretty inscrutable.

Views are converted in python code and that is executed on every
request, as models and controllers are. The syntax for importing
modules in view is pure python: {{import module}}. The module is
imported only once, when the first request arrives.

> I would almost certainly never remember it and have
> to look it up.  I think it involved the exec statement.  Is it obscure on
> purpose?)

No {{import modules}} in views is pure python. Probably you refer to
{{include ...}} and {{extend ...}}. They are not import nor exec.
Think of them as links in a tree: extend moves up, include moves down
tree branch. They just replace the statement with the included file
before the all tree collapses into python code and it is executed. If
ou click "compile" the bytecode compiled code associated to entire
view for each action is cached for speed.

> What about if I change the database schema in some way which makes the
> existing content incompatible with the new schema, say, by adding a new
> column name with notnull=True?

If you do it migration will fail unless the new column has a default
value and it will be used to populate the new column.

> More generally, where can I read about limitations in this read-and-continue
> environment?

Sorry. I do not understand the question.

>     Thadeus> In any case, web2py files are just python files stored on the
>     Thadeus> filesystem... you can edit them like you edit any other
>     Thadeus> programming languages files. You don't have to use the web2py
>     Thadeus> admin!!!!
>
> Right, I understand that completely.  I am/was concerned about the running
> web2py noticing changes.

the rule is simple. If the app is not "compiled" no change requires
restarting except changes in files in the modules/ folder. If the app
is compiled you need to click on "remove compiled" and "compiled"
again but no restart.

Massimo
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to