My best guess is that the problem is here:

dbutils.getAllColumns(pgdb_th2,session.nome_tabella)

and if session.nome_tabella contains something invalid you get an
invalid SQL query which aborts the transaction.

On Oct 20, 6:27 am, Manuele Pesenti <[email protected]> wrote:
> Hi,
> I'm trying to set up a controler with a form that reproduce some fields
> of a db table I have in my models because I want to mix information that
> goes in db table with other fields I need. The problem is when I try to
> reproduce a field (the last one here under) that is an external
> reference with this code:
>
> def import_from_db():
>      form2 = SQLFORM.factory(
>          Field('nome_tabella', length=32, requires =
> IS_IN_SET(dbutils.getTables(pgdb))),
>          Field('colonna_asse', length=32,
>              requires =
> IS_EMPTY_OR(IS_IN_SET(dbutils.getAllColumns(pgdb_th2,
> session.nome_tabella)))
>          ),
>          Field('grandezza', 'integer', required=True, requires =
> IS_EMPTY_OR(IS_IN_DB(pgdb_th2, 'grandezze.id', '%(id)s %(nome)s')))
> )
>
> adding this field when I try to view the form web2py gave me this error:
>
> InternalError: current transaction is aborted, commands ignored until
> end of transaction block
>
> the same code used inside my model definition (reported here under)
> works just fine rendering the table form through db administration
> interface.
>
> pgdb_th2.define_table('dati',
>      Field('asse', pgdb_th2.assi, required=True),
>      Field('grandezza', pgdb_th2.grandezze, required=True),
>      Field('valore', 'double', required=True),
>      Field('aggiornamento', 'date', default=None),
>      Field('scadenza', 'date', default=None),
>      Field('alt_take', 'integer', length=1, default=0),
> )
>
> pgdb_th2.dati.asse.requires = IS_EMPTY_OR(IS_IN_DB(pgdb_th2, 'assi.id',
> '%(id)s'))
> pgdb_th2.dati.grandezza.requires = IS_EMPTY_OR(IS_IN_DB(pgdb_th2,
> 'grandezze.id', '%(id)s %(nome)s'))
>
> Any idea about it?
>
> Thank you very much
>
>         Manuele

Reply via email to