There is an error in you query -- the "and" should be an "&". But that is 
not the source of your exception, which comes from the previous line that 
attempts to access the db.employee table. Apparently, at this point in the 
code, that table has not yet been defined (perhaps it is defined in a later 
model file, or defined in a conditional model file).

Anthony

On Sunday, April 5, 2015 at 10:51:46 PM UTC-4, 黄祥 wrote:
>
> hi,
>
> i have a query in is_in_db requires but not work properly
> e.g.
> *models/db.py*
> employee = db(db.employee.auth_user == 1).select().first()
> db.booking.room.requires = IS_IN_DB(db((db.room.status == 'Available') and 
> (db.room.branch == employee.branch)), db.room.id, db.room._format) if 
> auth.user else None
>
> *traceback*
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 227, in restricted
>     exec ccode in environment
>   File "C:/web2py/applications/hotel/models/db_wizard_4_booking.py" 
> <https://127.0.0.1/admin/default/edit/hostel/models/db_wizard_4_booking.py>, 
> line 3, in <module>
>     employee = db(db.employee.auth_user == 1).select().first()
>   File "C:\web2py\gluon\packages\dal\pydal\base.py", line 929, in __getattr__
>     return ogetattr(self, key)
> AttributeError: 'DAL' object has no attribute 'employee'
>
>
> *test on web2py python shell (work fine)*
> print db(db.employee.auth_user == 1).select().first()
> print db(db.room.branch == 1).select().first()
>
> employee = db(db.employee.auth_user == 1).select().first()
> print employee.branch
>
> is there related to modular dal?
>
> 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/d/optout.

Reply via email to