Based on your code, it appears the values of bevel and gosok_halus are not
in fact boolean but are the string values "on" or "None". You haven't shown
how the values were put into the session, so if you were expecting them to
be booleans, it's hard to say why they are not.
In any case, you can greatly simplify your code as follows:
for counter, (id, quantity, length_in_cm, width_in_cm, total_square_meter,
*bevel,
gosok_halus*) in session.delivery_order_detail.items():
db.delivery_order_detail.insert(delivery_order_no = delivery_order_id,
product = id,
quantity = quantity,
length_in_cm = length_in_cm,
width_in_cm = width_in_cm,
total_square_meter = total_square_meter,
*bevel = True if bevel == 'on' else
False,*
* gosok_halus = True if gosok_halus ==
'on' else False)*
Anthony
On Saturday, February 6, 2016 at 2:16:56 AM UTC-5, 黄祥 wrote:
>
> why during store boolean data type in session, always return true during
> insert?
> e.g. problem
> for counter, (id, quantity, length_in_cm, width_in_cm, total_square_meter,
> *bevel,
> gosok_halus*) in session.delivery_order_detail.items():
> db.delivery_order_detail.insert(delivery_order_no = delivery_order_id,
> product = id,
> quantity = quantity,
> length_in_cm = length_in_cm,
> width_in_cm = width_in_cm,
> total_square_meter = total_square_meter,
> *bevel = bevel,*
> * gosok_halus = gosok_halus)*
> e.g. solve
> for counter, (id, quantity, length_in_cm, width_in_cm, total_square_meter,
> *bevel,
> gosok_halus*) in session.delivery_order_detail.items():
> if bevel == 'None' and gosok_halus == 'None':
> db.delivery_order_detail.insert(delivery_order_no = delivery_order_id,
> product = id,
> quantity = quantity,
> length_in_cm = length_in_cm,
> width_in_cm = width_in_cm,
> total_square_meter = total_square_meter,
> bevel = False,
> gosok_halus = False)
> elif bevel == 'on' and gosok_halus == 'None':
> db.delivery_order_detail.insert(delivery_order_no = delivery_order_id,
> product = id,
> quantity = quantity,
> length_in_cm = length_in_cm,
> width_in_cm = width_in_cm,
> total_square_meter = total_square_meter,
> bevel = True,
> gosok_halus = False)
> elif bevel == 'None' and gosok_halus == 'on':
> db.delivery_order_detail.insert(delivery_order_no = delivery_order_id,
> product = id,
> quantity = quantity,
> length_in_cm = length_in_cm,
> width_in_cm = width_in_cm,
> total_square_meter = total_square_meter,
> bevel = False,
> gosok_halus = True)
> elif bevel == 'on' and gosok_halus == 'on':
> db.delivery_order_detail.insert(delivery_order_no = delivery_order_id,
> product = id,
> quantity = quantity,
> length_in_cm = length_in_cm,
> width_in_cm = width_in_cm,
> total_square_meter = total_square_meter,
> bevel = True,
> gosok_halus = True)
>
> i must manually explicit using if condition about the boolean value (*bevel,
> gosok_halus*), is it normal, or is there any better way rather than this
> one?
> 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.