If you set DAL(..., lazy_tables=True), most of the table definition code is deferred until the first time you call db.tablename, so tables that are not accessed on a given request are not fully defined. Of course, you can put the schema definition code into a function or class in a module and import and execute that function/class at request time, but the actual definition code would still have to run at each request (albeit, only for the tables you actually need for that request).
It sounds like instead, you would prefer for the module to create a table object so the table object can be imported directly (and then added to the DAL connection object of the current request) -- that way, the table object would be created only once, the first time it is imported. This isn't possible with the current API, though I suppose you could create instances of the dal.Table class in the module and then write your own version of DAL.define_table to attach the imported Table objects to a DAL instance. Perhaps this could be made an option of the current .define_table() method (as it is, if you pass a Table object to .define_table(), it just makes copies of all the Field objects, but perhaps there could be an option to pass in a Table object that gets used as is). Not sure how much benefit there would be to this approach, assuming any given request doesn't involve too many table definitions -- lazy_tables, conditional models, and importing functions/classes from modules may be sufficiently speedy for most use cases. Anthony On Thursday, January 16, 2014 3:34:35 AM UTC-5, Arnon Marcus wrote: > > Our schema is quite large (200+ Tables) and changes very seldom. > I was thinking, is there a way to not have to rebuild it in it's entierty > on every request? > I mean, is there a way to seperate-out the schema definition from the > connection object? Ideally, I would put the schema definition code in a > separate module in the modulesz folder, and import it into the model file > that creates the connecfion, and somehow pass the ready-made > schema-object(s) into the newly-created connection object on each request. > Can this be done? > What are the "gotchas" for this (if any)? > Are there restrictions for somed schema-definitions tbat can not be used > like this? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

