Web2py book says
>> When a new record is modified, including both insertions and updates, if
a value for the field is not provided, web2py tries to compute
For me this works well after UPDATE from SQLFORM.
However, when I use
db.table.insert(sourcefieldforcomputed=value)
computed field rem
Hi, I want to compute a field based on the value of another field, which is
a foreign key, in a way similar to:
db.define_table('language',
Field('language', 'string', required = True, unique = True, length = 64
),
format='%(language)s'
)
db.define_table('problemsHere',
Field('langu
I like to store the difference as integer not char(512)
db.define_table(
'mytable',
Field('begin_date', type='date', requires=IS_DATE(format='%Y.%m.%d.')),
Field('end_date', type='date', requires=IS_DATE(format='%Y.%m.%d.')),
Field('difference', compute=lambda r: r['end_date']-r['b
Hi,
I have defined a database table which has some fields which must be
computed:
agent_table = 'agent'
db.define_table(
agent_table,
Field('email',unique=True),
Field('agent_doc_id', length=128, compute=create_new_agent),
Field('password', 'password', len
http://web2py.com/books/default/chapter/29/6
{{extend 'layout.html'}}
Records
{{=SQLTABLE(rows,
headers='fieldname:capitalize',
truncate=100,
upload=URL('download'))
}}
Richard
On Fri, Apr 20, 2012 at 11:42 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:
> Also, you cou
Also, you could maybe search the book with "truncate" keyword, there is
already a utility if you just want to control the lenght of free text field
or other string field.
Richard
On Fri, Apr 20, 2012 at 11:35 AM, Richard Vézina <
ml.richard.vez...@gmail.com> wrote:
> I think you can't use comput
I think you can't use compute since you modify a field where the user as to
enter something base on the len of user input, so I think you should
transform the code below into function and use onvalidation=function
x=len(form.vars.description)
if x>128:
i=128
dots="..."
else:
i=x-1
I defined a table eventList:
db.define_table('EventList',
...
Field('description',type='text'),
Field('shortdescr',length=128,writable=False,readable=False),
migrate=False)
db.EventList.description.requires=IS_LENGTH(1536,error_message='length
exceeds 1536 characters')
db
Hello,
I notice that in the book the example shown don't define a field type for
compute. In that case web2py default seems to create a char var (512) type
field. I had no problem with this for storing the computation of decimal
result. It also works well if I define a proper field type, in my
Thanks a lot Richard! you were right! I have put the wrong field on the
calculation! You are the best!
Thank you!
On Wed, Feb 29, 2012 at 6:25 PM, Richard Vézina wrote:
> You valor_do_dolar field is still a problem in the model down here...
> Since you can't or your lambda can't accès valor_do_
You valor_do_dolar field is still a problem in the model down here... Since
you can't or your lambda can't accès valor_do_dolar in that example. The
field don't exist in the form so the key not exist so web2py return none
and custo_em_dolar*none will return none I guest.
try this :
db.define_tabl
Nice Catch, but I have commented the last field to apply what you suggested
and this also doesn't work:
db.define_table('compra_produto',
Field('compra', 'reference compra'),
Field('produto','reference produto'),
Field('quantidade','integer'),
Field('custo_em_dolar','double'),
F
You can't access valor_do_dolar from custo_em_real lambda computed since it
is a computed field that get computed un submit... If you want to do that
you will have to make a real function that get process on submit with
form.process().accepted and the argument onsuccess or onvalidation
See chapter
Here's what I would try:
Field('difference', compute=lambda u: (u['DT_FECHAMENTO '] -
u['DT_ABERTURA ']), label='Difference')
This is untested. I haven't used compute fields based on a math
function before, but like I said, this is what I'd try first.
Hope this helps.
-Jim
On 12/21/2
People,
How can I make the field NR_INDISPONIBILIDADE the table below
(chamado) in a computed field with the difference between the field
dates DT_FECHAMENTO and DT_ABERTURA.
Thank you,
db.define_table("chamados"
,Field('ID_CHAMADOS',type='id',readable=False)
,Field('ID_TECNICO
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
> eng
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_CID
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 =
Hi!!
I have 3 computed fields that call a "resize_image" function to make 3
versions of a uploaded image.
The definition of one of these fields:
Field('foto_portada_detalle', 'upload',
uploadfolder=request.folder+'static/uploads/actividades',
compute=lambda r: resize_image(r['foto_portada'], (20
Hello,
I have this code in a select function that work in command line to display
or not a computed field, so I can't figure out why it's not working in
app...
The computed field in red should not appear in grid view...
CONTROLLER :
elif auth.has_membership(auth.id_group('admin')):
fieldsBlackL
20 matches
Mail list logo