brilliant, never thought of that. thank you so much. yes i agree with you about the advantage of using models_to_run rather than importing tables from modules.
thanks and best regards, stifan On Tuesday, January 21, 2014 1:17:57 AM UTC+7, Anthony wrote: > > appadmin is just a controller, like any other, so it only sees models > defined in model files (note, there is special logic that runs all model > files when the appadmin controller is called, even if > response.models_to_run would normally make some models conditional). > appadmin can't know what models might be imported by other controllers. In > a model file, you could do something like: > > if request.controller == 'appadmin': > [code to import and define all models] > > I suppose one advantage of using models_to_run rather than importing from > modules is you get full appadmin functionality without a workaround like > the above. > > Anthony > > On Monday, January 20, 2014 10:19:12 AM UTC-5, 黄祥 wrote: >> >> hi anthony, >> >> */modules/mymodule.py:* >> >> from gluon import Field >> >> def mymodels(db): >> db.define_table('table1', Field('field1'), Field('field2')) >> db.define_table('table2', Field('field1'), Field('field2')) >> >> */models/db.py or /controllers/some_controller.py:* >> >> from mymodule import mymodels >> mymodels(db) >> >> in your example above, it said that the import can be on models and >> controllers, i've test both (put in models and in controllers), if i just >> put in controllers, the database administration (appadmin) for table1 and >> table2 is not shown, the database administration (appadmin) for table1 and >> table2 will shown if i import mymodels(db) in models. >> >> my question, is it possible to import mymodels in controllers yet still >> got access for database adminsitration (appadmin) for table1 and table2 >> without import it in models? >> >> ref: >> https://groups.google.com/forum/#!topic/web2py/b65mya4wamg >> >> thanks and best regards, >> stifan >> > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.