This is a bug in the new DAL. For now in production, please use stable
web2py. Anyway, this will be fixed soon.

On Dec 8, 6:42 pm, drayco <antrod...@gmail.com> wrote:
> Hi this the code in the controller:
>
> def form_factory(*a):
>     return SQLFORM(SQLDB(None).define_table(*a))
>
> def ventas():
>     form=form_factory('myform',
>
> SQLField('inicio','date',default=request.now.date(),requires=IS_NOT_EMPTY()),
>         SQLField('fin','date',default=request.now.date()))
>     total=''
>     regs=''
>     totalcorte=''
>     cortesias=''
>     totalc=''
>     cancel=''
>     totalgaran=''
>     garantias=''
>     totalcero=''
>     cero=''
>     inicio = ''
>     fin = ''
>     if form.accepts(request.vars,session):
>         response.flash='Formulario aceptado'
>         from datetime import datetime
>         inicio = datetime.strptime(str(form.vars.inicio) + "
> 00:00:00", "%Y-%m-%d %H:%M:%S")
>         if form.vars.fin==None:
>             fin = inicio
>             fin = fin.replace(hour=23,minute=59,second=59)
>         else:
>             fin = datetime.strptime(str(form.vars.fin) + " 23:59:59",
> "%Y-%m-%d %H:%M:%S")
>         Gerente = db.auth_user(user_id)
>         total =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia==None)&(db.notas.vale==None)).
> \
>
> select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> db.notas.id.count()),\
>             headers={'COUNT(notas.id)':'Num.Notas',
> 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> 'SUM(notas.pagos)':'Pagos',
> 'SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> COUNT(notas.id)':'Promedio'})
>         regs =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> ==
> Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia==None)&(db.notas.vale==None)).
> \
>
> select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> db.notas.id.count(),\
>             orderby=~(db.notas.total.sum()/
> db.notas.id.count()),groupby=db.notas.vendedor),\
>
> headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Num.Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> COUNT(notas.id)':'Promedio'})
>         totalc =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==False)).
> \
>
> select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum()),
> \
>             headers={'COUNT(notas.id)':'Num.Notas',
> 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> 'SUM(notas.pagos)':'Pagos', 'SUM(notas.saldo)':'Saldo'})
>         cancel =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> == Gerente.store_id)&(db.notas.active==False)).\
>
> select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),
> \
>             orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo'})
>         totalcorte =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.vale!
> =None)).\
>
> select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum()),
> \
>             headers={'COUNT(notas.id)':'Num.Notas',
> 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> 'SUM(notas.pagos)':'Pagos', 'SUM(notas.saldo)':'Saldo'})
>         cortesias =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> == Gerente.store_id)&(db.notas.active==True)&(db.notas.vale!=None)).\
>
> select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),
> \
>             orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo'})
>         totalgaran =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia!
> =None)).\
>
> select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> db.notas.id.count()),\
>             headers={'COUNT(notas.id)':'Num.Notas',
> 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> 'SUM(notas.pagos)':'Pagos',
> 'SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> COUNT(notas.id)':'Promedio'})
>         garantias =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> == Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia!
> =None)).\
>
> select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),db.notas.total.sum()/
> db.notas.id.count(),\
>             orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo','SUM(notas.total)/
> COUNT(notas.id)':'Promedio'})
>         totalcero =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id==Gerente.store_id)&(db.notas.active==True)&(db.notas.total==0)).
> \
>
> select(db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum()),
> \
>             headers={'COUNT(notas.id)':'Notas',
> 'SUM(notas.total)':'Total', 'SUM(notas.anticipo)':'Anticipo',
> 'SUM(notas.pagos)':'Pagos', 'SUM(notas.saldo)':'Saldo'})
>         cero =
> SQLTABLE(db((db.notas.created_on>inicio)&(db.notas.created_on<fin)&(db.notas.store_id
> == Gerente.store_id)&(db.notas.active==True)&(db.notas.garantia!
> =None)&(db.notas.vale!=None)&(db.notas.total==0)).\
>
> select(db.notas.vendedor,db.notas.id.count(),db.notas.total.sum(),db.notas.anticipo.sum(),db.notas.pagos.sum(),db.notas.saldo.sum(),
> \
>             orderby=~db.notas.id.count(),groupby=db.notas.vendedor),\
>
> headers={'notas.vendedor':'Vendedor','COUNT(notas.id)':'Notas','SUM(notas.total)':'Total','SUM(notas.anticipo)':'Anticipo','SUM(notas.pagos)':'Pagos','SUM(notas.saldo)':'Saldo'})
>     elif form.errors:
>         response.flash='Error en el formulario'
>     else:
>         response.flash='Por favor conteste el formulario'
>     return dict(form=form,total=total, regs=regs,
> totalcorte=totalcorte,cortesias=cortesias,
> totalc=totalc,cancel=cancel,
> totalgaran=totalgaran,garantias=garantias,inicio=inicio,fin=fin,totalcero=totalcero,cero=cero)
>
> It work in web2py 1.89.5, however after update trunk version it didn't
> work, it give me this error:
>
> Traceback (most recent call last):
>   File "/home/drayco/web2py/gluon/restricted.py", line 188, in
> restricted
>     exec ccode in environment
>   File "/home/drayco/web2py/applications/opticaluz/controllers/
> gerencia.py", line 1417, in <module>
>   File "/home/drayco/web2py/gluon/globals.py", line 95, in <lambda>
>     self._caller = lambda f: f()
>   File "/home/drayco/web2py/gluon/tools.py", line 2315, in f
>     return action(*a, **b)
>   File "/home/drayco/web2py/applications/opticaluz/controllers/
> gerencia.py", line 265, in ventas
>     SQLField('fin','date',default=request.now.date()))
>   File "/home/drayco/web2py/gluon/tools.py", line 2315, in f
>     return action(*a, **b)
>   File "/home/drayco/web2py/applications/opticaluz/controllers/
> gerencia.py", line 259, in form_factory
>     return SQLFORM(SQLDB(None).define_table(*a))
>   File "/home/drayco/web2py/gluon/sql.py", line 3204, in __init__
>     raise RuntimeError, "Adapter not supported"
> RuntimeError: Adapter not supported
>
> Can any have some advice to avoid that issue?

Reply via email to