You have to run at least one model file in order to set
response.models_to_run, so put the models_to_run code in a model file that
comes before db_wizard_news.py alphabetically. If you don't need to run any
model files after db_wizard_news.py, you can do something like:
if 'news' in request.function:
response.models_to_run = ['db_wizard_news.py']
After running the model file that contains the above statement, the only
additional model file to be run will be db_wizard_news.py. If you need to
run other model files as well, you can add regexes to the models_to_run
list (it might also be easier to put related model files into folders to
simplify the regexes).
Anthony
On Sunday, October 20, 2013 9:30:21 AM UTC-4, 黄祥 wrote:
>
> hi,
>
> i want to use response.models_to_run in my application, my code :
> *models/db_wizard_news.py*
> db.define_table('news',
> Field('title'),
> Field('contents', 'text'),
> format = '%(title)s')
>
> *controllers/default.py*
> def news():
> if len(request.args):
> page = int(request.args[0])
> else:
> page = 0
> items_per_page = 10
> limitby = (page * items_per_page, (page + 1) * items_per_page + 1)
> rows = db(db.news.is_active == True).select(limitby = limitby, orderby
> = ~db.news.id,
> cache = (cache.ram, 60), cacheable = True)
> return dict(rows = rows, page = page, items_per_page = items_per_page)
>
> *controllers/manage.py*
> def manage_news():
> grid=SQLFORM.grid(db.news, orderby = ~db.news.id, create = True,
> editable = True, deletable = True, details = True)
> return locals()
>
> how to use response.models_to_run in those condition?
>
> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.