[web2py] Re: Autocomplete problem ...

2013-01-31 Thread DenesL

Not an easy one.
For the widget to work properly the field names should be created at call 
time not at init time but the callback uses the one from init.
Minimizing backward incompatibilities is another concern.

As an additional enhancement it could take a query to define a subset of 
the values. 


On Tuesday, January 29, 2013 9:18:31 AM UTC-5, Massimo Di Pierro wrote:

 Can you submit a patch?

 On Tuesday, 29 January 2013 05:36:53 UTC-6, DenesL wrote:


 You have found a bug.

 The problem is that identical field names are being generated in the form 
 for both Relation fields:
 input autocomplete=off class=string id=Relation_contact 
 name=_autocomplete_Person_name_aux ...
 input autocomplete=off class=string id=Relation_name 
 name=_autocomplete_Person_name_aux ...
 input id=_autocomplete_Person_name_auto name=name type=hidden 
 value= /
 input id=_autocomplete_Person_name_auto name=contact type=hidden 
 value= /





-- 

--- 
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/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread Ivan Gazzola
I've deleted the db but error still remains ...



Il giorno lunedì 28 gennaio 2013 16:32:10 UTC+1, Massimo Di Pierro ha 
scritto:

 I think your problem is corrupted data. You have Pippo Pippo in a field 
 that is either integer or reference. This can happen with sqlite if you 
 change a field type. Delete the database and start again. I do not think 
 there is anything wrong with your code.

 On Sunday, 27 January 2013 15:51:33 UTC-6, Ivan Gazzola wrote:

 Il giorno giovedì 24 gennaio 2013 18:56:59 UTC+1, Massimo Di Pierro ha 
 scritto:


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 db.Relation.contact.widget=SQLFORM.widgetsre.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 should be


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,name,id_field=
 db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)




 I forgot to write name in previus post  but the model was ok. Really my 
 model is more complex:

 db.define_table('Nominativi',
 Field('nome',notnull=True, represent=lambda nome:nome.title()),
 Field('categoria',db.Categorie_Nominativi,default='1'),
 Field('sesso',requires=IS_NULL_OR(IS_IN_SET(['maschio','femmina']))),
 Field('mail',requires=IS_NULL_OR(IS_EMAIL(error_message=T('Inserire 
 Una Mail Valida',
 Field('indirizzo'),
 Field('localita', label='Località'),
 Field('cap',requires=IS_NULL_OR(IS_LENGTH(5,5, 
 error_message=T('Inserire Un CAP valido',
 Field('provincia',requires=IS_NULL_OR(IS_IN_SET(Elenco_Province, 
 zero=T('Selezionare una Provincia',
 Field('codice_fiscale',length=20),
 Field('partita_iva',length=20),
 Field('data_di_nascita','date'),
 Field('professione'),
 Field('padre'),
 Field('madre'),
 Field('inviato_da'),
 Field('id_precendente','integer'),
 format=lambda 
 r:r.nome.title()+'--'+db.Categorie_Nominativi(r.categoria)['categoria'])



 db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
 db.Nominativi.categoria.represent = lambda id,row: row.categoria
 db.Nominativi.nome.represent = lambda nome,row: nome.title()

 db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)


 db.define_table('Relazioni',
 Field('nominativo',db.Nomiantivi,required=True),
 Field('referente',db.Nominativi,required=True))

 db.Relazioni.nominativo.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id)

 db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id)

 The error log:
 type 'exceptions.ValueError' invalid literal for int() with base 10: 
 'Pippo Pippo'
 and 'pippo pippo' was the value of 'referente'.

 If i try a simplified model like that i posted before, i can insert the 
 new record but the 'contact' value is stored in 'name' field and 'contact' 
 field is always '0'.

 db.define_table('Person', Field('name'), format='%(name)s')
 db.define_table('Relation', Field('name',db.Person), 
 ('contact',db.Person))
 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)

 I suppose that ajax request lose some data, it would store only the last 
 call to table Person ...



-- 

--- 
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/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread DenesL

You have found a bug.

The problem is that identical field names are being generated in the form 
for both Relation fields:
input autocomplete=off class=string id=Relation_contact 
name=_autocomplete_Person_name_aux ...
input autocomplete=off class=string id=Relation_name 
name=_autocomplete_Person_name_aux ...
input id=_autocomplete_Person_name_auto name=name type=hidden 
value= /
input id=_autocomplete_Person_name_auto name=contact type=hidden 
value= /



-- 

--- 
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/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread Massimo Di Pierro
Can you submit a patch?

On Tuesday, 29 January 2013 05:36:53 UTC-6, DenesL wrote:


 You have found a bug.

 The problem is that identical field names are being generated in the form 
 for both Relation fields:
 input autocomplete=off class=string id=Relation_contact 
 name=_autocomplete_Person_name_aux ...
 input autocomplete=off class=string id=Relation_name 
 name=_autocomplete_Person_name_aux ...
 input id=_autocomplete_Person_name_auto name=name type=hidden 
 value= /
 input id=_autocomplete_Person_name_auto name=contact type=hidden 
 value= /





-- 

--- 
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/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-29 Thread Massimo Di Pierro
Mind I think it should be possible to do:

auto = 
SQLFORM.widgets.autocomplete(request,db.Person,id_field=db.Person.idhttp://db.person.id/
)

db.define_table('Person', Field('name'), format='%(name)s')
db.define_table('Relation', Field('name',db.Person), ('contact',db.Person))
db.Relation.name.widget=auto
db.Relation.contact.widget=auto

On Tuesday, 29 January 2013 05:36:53 UTC-6, DenesL wrote:


 You have found a bug.

 The problem is that identical field names are being generated in the form 
 for both Relation fields:
 input autocomplete=off class=string id=Relation_contact 
 name=_autocomplete_Person_name_aux ...
 input autocomplete=off class=string id=Relation_name 
 name=_autocomplete_Person_name_aux ...
 input id=_autocomplete_Person_name_auto name=name type=hidden 
 value= /
 input id=_autocomplete_Person_name_auto name=contact type=hidden 
 value= /





-- 

--- 
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/groups/opt_out.




[web2py] Re: Autocomplete problem ...

2013-01-28 Thread Massimo Di Pierro
I think your problem is corrupted data. You have Pippo Pippo in a field 
that is either integer or reference. This can happen with sqlite if you 
change a field type. Delete the database and start again. I do not think 
there is anything wrong with your code.

On Sunday, 27 January 2013 15:51:33 UTC-6, Ivan Gazzola wrote:

 Il giorno giovedì 24 gennaio 2013 18:56:59 UTC+1, Massimo Di Pierro ha 
 scritto:


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 db.Relation.contact.widget=SQLFORM.widgetsre.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 should be


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,name,id_field=
 db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)




 I forgot to write name in previus post  but the model was ok. Really my 
 model is more complex:

 db.define_table('Nominativi',
 Field('nome',notnull=True, represent=lambda nome:nome.title()),
 Field('categoria',db.Categorie_Nominativi,default='1'),
 Field('sesso',requires=IS_NULL_OR(IS_IN_SET(['maschio','femmina']))),
 Field('mail',requires=IS_NULL_OR(IS_EMAIL(error_message=T('Inserire 
 Una Mail Valida',
 Field('indirizzo'),
 Field('localita', label='Località'),
 Field('cap',requires=IS_NULL_OR(IS_LENGTH(5,5, 
 error_message=T('Inserire Un CAP valido',
 Field('provincia',requires=IS_NULL_OR(IS_IN_SET(Elenco_Province, 
 zero=T('Selezionare una Provincia',
 Field('codice_fiscale',length=20),
 Field('partita_iva',length=20),
 Field('data_di_nascita','date'),
 Field('professione'),
 Field('padre'),
 Field('madre'),
 Field('inviato_da'),
 Field('id_precendente','integer'),
 format=lambda 
 r:r.nome.title()+'--'+db.Categorie_Nominativi(r.categoria)['categoria'])



 db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
 db.Nominativi.categoria.represent = lambda id,row: row.categoria
 db.Nominativi.nome.represent = lambda nome,row: nome.title()

 db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)


 db.define_table('Relazioni',
 Field('nominativo',db.Nomiantivi,required=True),
 Field('referente',db.Nominativi,required=True))

 db.Relazioni.nominativo.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id)

 db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id)

 The error log:
 type 'exceptions.ValueError' invalid literal for int() with base 10: 
 'Pippo Pippo'
 and 'pippo pippo' was the value of 'referente'.

 If i try a simplified model like that i posted before, i can insert the 
 new record but the 'contact' value is stored in 'name' field and 'contact' 
 field is always '0'.

 db.define_table('Person', Field('name'), format='%(name)s')
 db.define_table('Relation', Field('name',db.Person), ('contact',db.Person))
 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)

 I suppose that ajax request lose some data, it would store only the last 
 call to table Person ...


-- 





[web2py] Re: Autocomplete problem ...

2013-01-27 Thread Ivan Gazzola
Il giorno giovedì 24 gennaio 2013 18:56:59 UTC+1, Massimo Di Pierro ha 
scritto:


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 db.Relation.contact.widget=SQLFORM.widgetsre.autocomplete(request,db.Person,id_field=
 db.Person.id http://db.person.id/)

 should be


 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,name,id_field=
 db.Person.id http://db.person.id/)
 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
 db.Person.name,id_field=db.Person.id http://db.person.id/)




I forgot to write name in previus post  but the model was ok. Really my 
model is more complex:

db.define_table('Nominativi',
Field('nome',notnull=True, represent=lambda nome:nome.title()),
Field('categoria',db.Categorie_Nominativi,default='1'),
Field('sesso',requires=IS_NULL_OR(IS_IN_SET(['maschio','femmina']))),
Field('mail',requires=IS_NULL_OR(IS_EMAIL(error_message=T('Inserire Una 
Mail Valida',
Field('indirizzo'),
Field('localita', label='Località'),
Field('cap',requires=IS_NULL_OR(IS_LENGTH(5,5, 
error_message=T('Inserire Un CAP valido',
Field('provincia',requires=IS_NULL_OR(IS_IN_SET(Elenco_Province, 
zero=T('Selezionare una Provincia',
Field('codice_fiscale',length=20),
Field('partita_iva',length=20),
Field('data_di_nascita','date'),
Field('professione'),
Field('padre'),
Field('madre'),
Field('inviato_da'),
Field('id_precendente','integer'),
format=lambda 
r:r.nome.title()+'--'+db.Categorie_Nominativi(r.categoria)['categoria'])


db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
db.Nominativi.categoria.represent = lambda id,row: row.categoria
db.Nominativi.nome.represent = lambda nome,row: nome.title()
db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)


db.define_table('Relazioni',
Field('nominativo',db.Nomiantivi,required=True),
Field('referente',db.Nominativi,required=True))
db.Relazioni.nominativo.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=db.Nominativi.id)
db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=db.Nominativi.id)

The error log:
type 'exceptions.ValueError' invalid literal for int() with base 10: 
'Pippo Pippo'
and 'pippo pippo' was the value of 'referente'.

If i try a simplified model like that i posted before, i can insert the new 
record but the 'contact' value is stored in 'name' field and 'contact' 
field is always '0'.

db.define_table('Person', Field('name'), format='%(name)s')
db.define_table('Relation', Field('name',db.Person), ('contact',db.Person))
db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person.name,id_field=
db.Person.id http://db.person.id/)
db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,db.Person.name,id_field=
db.Person.id http://db.person.id/)

I suppose that ajax request lose some data, it would store only the last 
call to table Person ...

-- 





[web2py] Re: Autocomplete problem ...

2013-01-24 Thread Massimo Di Pierro
db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
db.Person.id http://db.person.id/)
db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
db.Person.id http://db.person.id/)

should be

db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,name,id_field=
db.Person.id http://db.person.id/)
db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,db.Person.name,id_field=
db.Person.id http://db.person.id/)

On Thursday, 24 January 2013 09:35:32 UTC-6, Ivan Gazzola wrote:

 I'm trying my first application in web2py.

 I've this model

 db.define_table('Person', Field('name'), format='%(name)s')
 db.define_table('Relation', Field('name',db.Person), ('contact',db.Person))

 db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
 db.Person.id)

 db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
 db.Person.id)

 When i try to insert a new record in Relation from appadmin i can't do for 
 type mismatch, the form post db.Person.name value, not db.Person.id as i 
 expected ...

 I use web2py 2.3.2 for win. 

 any suggestions???


--