I had round after float. Thanks!

On May 10, 11:42 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> it is a good idea but somebody has to implement that. It would be in
> the new DAL, not current DAL, and it is not clear it is supported by
> all backends. Were you doing to provide a list of databases that
> support the double quotes with examples?
>
> On May 10, 10:00 pm, Álvaro Justen <alv...@justen.eng.br> wrote:
>
> > On Sun, May 9, 2010 at 00:38, mdipierro <mdipie...@cs.depaul.edu> wrote:
> > > There are two problems:
> > > 1)  order is reserved keyword.
>
> > Yes but about the quotes that I suggested? :-)
>
> > > 2) decimal types are treated as string internally and there for
> > > compute should be
>
> > > db.order.tipgranted.compute=lambda r:
> > > float(r['totalsale'])*float(r['tipvalue'])
>
> > > or better
>
> > > db.order.tipgranted.compute=lambda r:
> > > decimal.Decimal(r['totalsale'])*decimal.Decimal(r['tipvalue'])
>
> > > On May 8, 10:00 pm, greenpoise <danel.sega...@gmail.com> wrote:
> > >> Model:
>
> > >> db.define_table('order',
> > >>     Field('employee',db.person),
> > >>     Field('tablenumber'),
> > >>     Field('ordernumber'),
> > >>     Field('orderdate','date'),
> > >>     Field('totalsale', 'decimal(10,2)'),
> > >>     Field('tipgranted', 'decimal(10,2)',default=None, update=None,
> > >> readable=False),
> > >>     Field('tipvalue','decimal(10,2)',default='0.15'),)
>
> > >> @auth.requires_login()
> > >> def show_orders():
> > >>     db.order.tipgranted.compute=lambda r:
> > >> r['totalsale']*r['tipvalue']
> > >>     form=crud.create(db.order)
>
> > >> orders=db(db.order.employee==employee.id).select(orderby=db.order.ordernumber)
> > >>     return dict(employee=employee,orders=orders,form=form)
>
> > >> thanks
>
> > >> On May 8, 10:54 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > >> > Can you show us the model and the action that triggers this?
>
> > >> > On May 8, 9:49 pm, greenpoise <danel.sega...@gmail.com> wrote:
>
> > >> > > Can someone help me. I am trying to do a simplecalculationof fields.
> > >> > > Fields are defined as decimal in db.py and here is thecalculation:
>
> > >> > >     db.order.tipgranted.compute=lambda r: 
> > >> > > r['totalsale']*r['tipvalue']
>
> > >> > > error: TypeError: can't multiply sequence by non-int of type 'float'
>
> > --
> > Álvaro Justen - Turicas
> >  http://blog.justen.eng.br/
> >  21 9898-0141

Reply via email to