Are you running web2py 2.7.4? There was an error related to models_to_run 
in prior versions.

On Sunday, October 20, 2013 6:41:34 PM UTC-4, 黄祥 wrote:
>
>
>
>> if 'news' in request.function:
>>     response.models_to_run = ['db_wizard_news.py']
>>
>> it's work, thanks, anthony, because i start from simple to learn how 
> response.models_to run works, but i need to run other models too. i've 
> followed your suggestion to make a folder for each models to run and put 
> the models file and menu inside those folder, and found a lot of problems. 
> my models structure is like :
> models
> - news
> -- db_wizard_news.py
> -- menu.py
> - service
> -- db_wizard_service.py
> -- menu.py
> db.py
> menu.py
>
> 1. i use a query in menu that refer to the other tables. e.g.
> models/menu.py and models/db_wizard_news/menu.py and 
> models/db_wizard_service/menu.py
> rows = db(db.company.id == 1).select(cache = (cache.ram, 60), cacheable = 
> True)
> for row in rows:
> response.logo = A(IMG(_src=URL('static', 'images/logo/%s' % row.logo), 
>   _width="20px", _title=row.name, _class="brand"), 
>   _target='_blank', _href='%s' % row.website)
>
>     services = db(db.service).select(orderby = db.service.id, cache = 
> (cache.ram, 60), cacheable = True)
>     services_menu = [] 
>     for service in services: 
>         services_menu.append((T(service.title), False, 
>                                URL('default', 'service', args = service.id
> )))
>
>     response.menu += [
>         (T('Service'), False, None, services_menu) 
>     ]
>
> it return an error :
>
> AttributeError: 'DAL' object has no attribute 'company'
>
> eventhough i've define db.company in db.py
> 2. in controller i use a query too but return same error too e.g.
> controller/default.py
> def index():
> session.forget(response)
> rows = db(db.company.is_active== True).select(orderby = ~db.company.id, 
> cache = (cache.ram, 60), cacheable = True)
> return dict(rows = rows)
>
> 3. i have auth_user table that refer to company table and i plan to make 
> it separate like news and service table
>
> any suggestion how to handle this situation in web2py way?
>
> fyi, i start the application from scratch to learn response.models_to_run, 
> so that the database tables is not there in the first place.
>
> 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.

Reply via email to