commas at the beginning of a line is not a common practice, but not
necessarily a bad one.  I use it myself, having been bitten by too many
missing commas too often. ;)

On Tuesday, December 20, 2011, Richard Vézina wrote:

> I have difficulty to understand your models because they are not in
> english (sorry about that)... I will try to help anyway...
>
> By the way you should put "," at the end of your lines like this :
>
> Field('CD_CIDADAO',type='**string',notnull=True,label='**Matrícula')*,*
>
> instead of :
>
> *,*Field('CD_CIDADAO',type='**string',notnull=True,label='**Matrícula')
>
> Because python will not understand, maybe web2py does, but it is not a
> good pratice...
>
> You use format =... But you don't use web2py fk fearture so format= can't
> manage your reprensentation...
>
> For example :
>
> representante table field : CD_CIDADAO field definition should be :
>
>
> Field('CD_CIDADAO',db.cidadao)
>
>  So CD_CIDADAO will be of type integer and store the id of the cidadao
> table... That way web2py should generate a dropbox and use "format="
> of cidadao table to  avoid displaying the id of the field that has no
> meaning for end user... Then you will have to use represente=
> for CD_CIDADAO field to make sure that on retreiving of the result you not
> having the id instead of what you want the user to see...
>
>
> db.representante.CD_CIDADAO.represent=lambda id, row:
> db.cidadao(id).NM_CIDADAO
>
>
> Hope it helps
>
> Richard
>
>
> On Mon, Dec 19, 2011 at 10:10 AM, Jose Carlos Junior 
> <josec...@gmail.com>wrote:
>
>> Please...I have some dificult in do this in web2py...as follow
>>
>> db.define_table("cidadao"
>>     ,Field('CD_CIDADAO',type='id',
>> **label='Cidadão(PK)')
>>     ,Field('CD_MATRICULA',type='**integer',notnull=True,label='**
>> Matrícula')
>>     ,Field('NM_CIDADAO',type='**string',notnull=True,label='**Nome')
>>     ,format = '%(NM_CIDADAO)s'
>>     ,singular = 'cidadao'
>>     ,plural = 'cidadaos'
>>     ,migrate=False)
>>
>>
>> db.define_table("**representante"
>>     ,Field('ID_REPRESENTANTE',**type='id',readable=False)
>>     ,Field('ID_CARGOS',type='**integer',notnull=True,label='**Cargo')
>>     ,Field('CD_CIDADAO',type='**string',notnull=True,label='**Matrícula')
>>     ,Field('DT_INCLUSAO',type='**datetime',notnull=True,label='**
>> Inclusão')
>>     ,Field('DT_EXCLUSAO',type='**datetime',notnull=False,label=**
>> 'Exclusão')
>>     ,Field('CD_TELEFONE',type='**string',notnull=True,label='**Telefone')
>>     ,Field('CD_EMAIL',type='**string',notnull=True,label='**Email')
>>     ,Field('CD_CELULAR',type='**string',notnull=False,label='**Celular')
>>     ,migrate=False)
>>
>> db.representante.CD_CIDADAO.**requires = IS_IN_DB(db,
>> 'cidadao.CD_CIDADAO', '%(CD_MATRICULA)s - %(NM_CIDADAO)s')
>> db.representante.ID_CARGOS.**requires = IS_IN_DB(db, 'cargos.ID_CARGOS',
>> '%(NOME)s')
>>
>> db.define_table("gtils_**representante"
>>     ,Field('ID',type='id',**readable=False)
>>     ,Field('ID_GTIL',readable=**True,label='GTIL')
>>     ,Field('ID_REPRESENTANTE',**readable=True,label='**Representante')
>>     ,Field('DT_INICIO',type='**datetime',notnull=True,label='**Início')
>>     ,Field('DT_TERMINO',type='**datetime',notnull=False,label=**
>> 'Término')
>>     ,migrate=False)
>>
>> db.gtils_representante.ID_**GTIL.requires = IS_IN_DB(db,
>> 'gtils.ID_GTIL', '%(NOME)s')
>>
>> How can i fill  ID_REPRESENTANTE but show NM_CIDADAO (table cidadao) once
>> i don't have this field in "representante" table...??  or how can i put a
>> computed field in 'representant' table filled with the result  choice of
>> the CD_CIDADAO. Thanks alot
>>
>
>

Reply via email to