just curious, is it possible to add the format function in the table room?
*e.g. 1. no error but the result is not expected*
db.define_table('room',
Field('room_no'),
Field('category', 'list:string'),
Field('status', 'list:string'),
Field('branch', 'reference branch'),
format=lambda r: format_room)
db.define_table('booking',
Field('scheduled_start', 'datetime'),
Field('due_date', 'datetime'),
Field('room', 'reference room'),
Field('guest', 'reference guest'),
Field('description', 'text'),
format='%(scheduled_start)s %(guest)s %(room)s')
my view is return :
<function format_room at 0x7fd17c27c758>
*e.g. 2. got an error*
db.define_table('room',
Field('room_no'),
Field('category', 'list:string'),
Field('status', 'list:string'),
Field('branch', 'reference branch'),
format=lambda r: format_room(r.room))
db.define_table('booking',
Field('scheduled_start', 'datetime'),
Field('due_date', 'datetime'),
Field('room', 'reference room'),
Field('guest', 'reference guest'),
Field('description', 'text'),
format='%(scheduled_start)s %(guest)s %(room)s')
Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
Traceback (most recent call last):
File "/host/Downloads/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/host/Downloads/web2py/applications/hotel/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/hotel/controllers/default.py>, line
187, in <module>
File "/host/Downloads/web2py/gluon/globals.py", line 194, in <lambda>
self._caller = lambda f: f()
File "/host/Downloads/web2py/gluon/tools.py", line 2971, in f
return action(*a, **b)
File "/host/Downloads/web2py/applications/hotel/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/hotel/controllers/default.py>, line
99, in booking
editable=has_membership, deletable=has_membership)
File "/host/Downloads/web2py/gluon/sqlhtml.py", line 2296, in grid
value = field.represent(value, row)
File "/host/Downloads/web2py/gluon/dal.py", line 6673, in repr_ref
def repr_ref(id, row=None, r=referenced, f=ff): return f(r, id)
File "/host/Downloads/web2py/gluon/dal.py", line 6650, in ff
return r._format(row)
File "/host/Downloads/web2py/applications/hotel/models/db_wizard.py"
<http://127.0.0.1:8000/admin/default/edit/hotel/models/db_wizard.py>, line 39,
in <lambda>
format=lambda r: format_room(r.room))
AttributeError: 'Row' object has no attribute 'room'
*e.g. 3. got an error*
db.define_table('room',
Field('room_no'),
Field('category', 'list:string'),
Field('status', 'list:string'),
Field('branch', 'reference branch'),
format=lambda id, r: format_room(r.room))
db.define_table('booking',
Field('scheduled_start', 'datetime'),
Field('due_date', 'datetime'),
Field('room', 'reference room'),
Field('guest', 'reference guest'),
Field('description', 'text'),
format='%(scheduled_start)s %(guest)s %(room)s')
Traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
Traceback (most recent call last):
File "/host/Downloads/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/host/Downloads/web2py/applications/hotel/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/hotel/controllers/default.py>, line
187, in <module>
File "/host/Downloads/web2py/gluon/globals.py", line 194, in <lambda>
self._caller = lambda f: f()
File "/host/Downloads/web2py/gluon/tools.py", line 2971, in f
return action(*a, **b)
File "/host/Downloads/web2py/applications/hotel/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/hotel/controllers/default.py>, line
99, in booking
editable=has_membership, deletable=has_membership)
File "/host/Downloads/web2py/gluon/sqlhtml.py", line 2296, in grid
value = field.represent(value, row)
File "/host/Downloads/web2py/gluon/dal.py", line 6673, in repr_ref
def repr_ref(id, row=None, r=referenced, f=ff): return f(r, id)
File "/host/Downloads/web2py/gluon/dal.py", line 6650, in ff
return r._format(row)
TypeError: <lambda>() takes exactly 2 arguments (1 given)
--
---
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.