Upon each request, web2py scans the filesystem, loading
model/controller/view python files into a list of filenames. When a
request comes in, it then uses exec to execute the python file in the
current globals() (which is why you don't have to import web2py
things). So if the class/function is already defined, it gets
redefined (note, modules get imported, you can import a module by
`local_import('modulename')).

If you change the schema to an incompatible format that web2py cannot
possibly migrate... well then you just don't have the migration, so if
you define notnull=True... the underlying database will not have a
null for that field. You would need to delete you database, and start
from scratch to have correct table definitions.

So the reason that web2py notices changes is not because it is looks
at the timestamp... it is because models and controllers are always
ran with exec upon each request. Regardless of if they are changed or
not, hence, executed not imported.

-Thadeus





On Tue, Jan 5, 2010 at 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?  What about classes defined in those files?  Are existing instances
> somehow brought up-to-date?  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.  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?)
>
> 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?
>
> More generally, where can I read about limitations in this read-and-continue
> environment?
>
>    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.
>
> Skip
>
> --
> 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.
>
>
>
>
-- 
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