the task definitely runs in a fresh environment, but as it stands your 
explanation doesn't give me enough details to build a proof of concept.
if you have some  - even weird - code that basically looks up the 
"projects" table to build definitions of tables, then if that piece of code 
is executed in the task you should be perfectly fine.
The only thing I can reproduce is that a task defined as 

def mytest_models():
     db.define_table('whatever',
     Field('afield')
     )
     db.whatever.insert(afield='foo')
     db.commit()

works as intended.

On Wednesday, May 8, 2013 6:02:07 PM UTC+2, DeanK wrote:
>
> So one of my model files is somewhat unique (and possibly a bad idea) and 
> causing me problems...I'll try to describe things the best I can.
>
> My application creates tables dynamically based on user input.  To stop 
> web2py from defining all the tables on every request (which can be a lot in 
> the whole app, but only 10ish per user), I check which tables the user has 
> access to and define only those.  This is done by looking at a table 
> (projects) where each record specifies other tables that exist (the project 
> support tables).
>
> The issue i'm having is the user fills out a form using smartgrid.  In the 
> oncreate callback I update the projects table which essentially specifies 
> new tables.  These new tables are not defined unless the model runs again. 
>  I know this will happen on a refresh, but is there any other way to force 
> the models to update?
>
>
> If I then submit a job to the scheduler that references one of these "new" 
> tables I get this error:
>
> 'DAL' object has no attribute 'test_project_proj'
>
> Where test_project_proj one of the support tables that should have been 
> defined (in the model snippet below project.project_table = 
> 'test_project_proj') .
>
>
>
> Example of key part of the model:
>
>
> user_allowed_ids = get_user_allowed_projects(False) for project in db(db.
> projects.id.belongs(user_allowed_ids)).select():
>     db.define_table(project.project_table,......)
>     db.define_table(project.block_table,......)
>     db.define_table(project.metadata_table,......)
>
>
>     
>
> I thought that when a job runs on the scheduler it re-runs all the models, so 
> i don't understand why the task isn't seeing the new tables.  Thoughts?  
> Thanks
>
>
>
> Dean
>
>
>
>
>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to