Please open a Github issue (linking to this thread), as this is a bug that was recently introduced. Field objects must now be cloned, but the new code does not take into account that arguments to SQLFORM.factory can also be tables (which do not have a .clone() method).
Anthony On Wednesday, July 26, 2017 at 10:41:58 AM UTC-4, joaovictor...@poli.ufrj.br wrote: > > I'm trying to expose a form with 2 SQLite tables behind it. I read the > documentation, > did as recommended and got the following error: > > Traceback (most recent call last): > File "/home/joao/Desktop/web2py/gluon/restricted.py", line 219, in > restricted > exec(ccode, environment) > File "/home/joao/Desktop/web2py/applications/vr/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/vr/controllers/default.py>, line > 101, in <module> > File "/home/joao/Desktop/web2py/gluon/globals.py", line 409, in <lambda> > self._caller = lambda f: f() > File "/home/joao/Desktop/web2py/applications/vr/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/vr/controllers/default.py>, line > 55, in register_student > form = SQLFORM.factory(db.Pessoa,db.Aluno) > File "/home/joao/Desktop/web2py/gluon/sqlhtml.py", line 1922, in factory > return SQLFORM(DAL(None).define_table(table_name, *[field.clone() for > field in fields]), > AttributeError: 'Table' object has no attribute 'clone' > > > > These are my controller and model: > Model: > db.define_table('Pessoa', > Field('nome',required=True,notnull=True), > Field('cpf',required=False,notnull=True,length=11), > Field('data_de_nascimento',type='date',required=False,notnull=True), > Field('cep',notnull=True,length=8), > Field('uf',notnull=True,length=2), > Field('pai',notnull=True), > Field('mae',notnull=True), > Field('identidade',notnull=True,length=13), > Field('expedicao_identidade',type='date',required=False,notnull=True), > Field('tipo_sanguineo',notnull=True,length=3), > Field('orgao_emissor',notnull=True,length=20), > Field('doador',type='boolean', notnull=True), > Field('origem',notnull=True,length=40), > Field('observacao',notnull=True), > auth.signature, > ) > db.define_table('Aluno', > Field('pessoa_id', 'reference Pessoa', writable=False, readable=False), > # Field('nota_fiscal_id', 'reference Nota_fiscal', writable=False, > readable=False), > Field('matricula', notnull=True, length=7), > Field('renach', notnull=True, length=40), > Field('categoria', notnull=True, length=5), > Field('servico', notnull=True), > Field('status', notnull=True), > auth.signature, > ) > > Controller: > def register_student(): > form = SQLFORM.factory(db.Pessoa,db.Aluno) > > if form.process().accepted: > > id = db.Pessoa.insert(**db.Pessoa._filter_fields(form.vars)) > form.vars.client=id > id = db.Aluno.insert(**db.Aluno._filter_fields(form.vars)) > response.flash='Aluno cadastrado com sucesso!' > > return dict(form=form) > > As I said, the controller is like what I read in documentation. > If someone can help I'll be grateful. > > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.