Thanks for help, I will check T3.

I still not understand why table define in model/db.py  only need
define once,  then  all sub-sequence requests can access it without
execute db.define_table  at every request,  but table define in
default.py need execute db.define_table at every request.



On Sep 11, 3:41 pm, mdipierro <[email protected]> wrote:
> The db.define_table(...) does two things:
> 1) the first time it is executed it creates the table
> 2) the other times it is executed it informs web2py that you expect to
> have that table (if not it is recreated or migrated accordingly).
>
> This means it has to be executed at every request. Not just in one
> controller.
>
> You can have a user click a button and create a table but the info
> about that table also have to be stored in the database so that it can
> be retrieved on sub-sequence requests.
>
> T3 does it. Look into the source code.
>
> On Sep 11, 12:32 am, wf321 <[email protected]> wrote:
>
>
>
> > I try let end user create their table on fly , for example, in
> > default.py
>
> > I have 2 function
>
> > def somepage()
> >     if not db.has_key('sometable'):
> >         db.define_table('sometable', ....
>
> >     redurect(r-request, f='nextpage')
>
> > def nextpage()
> >     if not db.has_key('sometable'):
> >        showerror()
>
> > when user call somepage(), it do create a new table 'sometable' in
> > database, after redirect
> > to nextpage(),  'sometable' still in database,  but db.has_key
> > ('sometable') retun false,
>
> > does anyone know what happen?
>
> > and if change nextpage to   db.has_key('db_py_table') ( db_py_table is
> > define model\db.py ) it retuen true.
>
> > Can anyone help to tell me how to code to  create table in controler
> > py and it can access by other function?
>
> > Thanks a lot.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to