[web2py:30689] how to let end user (not developer) define table on fly
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. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@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 -~--~~~~--~~--~--~---
[web2py:30696] Re: how to let end user (not developer) define table on fly
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 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 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 web2py@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 -~--~~~~--~~--~--~---
[web2py:32930] tempory table and store procedure
in web2py is there anything like tempory table and store procedure ? people not suggest to use tempory table for DAL but what is the good solution to handle complex query? For example, there are tables A,B,C,D,E ... 1) result1 = join A,B,C 2) update some rows in result1 3) then base on rows count of result1, need join result1 to different table (C.. or D,E..) and return different fields handle this can use tempory table in store procedure in database , anyone know how to do it in web2py with DAL (not db.executesql ) ? thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@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 -~--~~~~--~~--~--~---