compute=  works for me once, when I create a record (or when Field==None).
And that is exactly what you write in documentation.

But I need calculated field which updates always when source fields will
change.
Maybe proper way is to use default=(or compute=)+update=  ?

I'm sorry for late response. Thats because I no need solution: Earlier I
wanted implement MARKMIN translation and I had MARKMIN(source) and
HTML(converted, computed) document in 2 fields of same table.

However now I decided to implement Plugin Wiki with MARKMIN, widgets &
template language, which of course need dynamic evaluation - and I no
longer need computing after source editing.

However the answer (how to properly calculate field always, after Insert
and Update) would be interesting.

Many greetings and great thanks for your work.
Best regards,
Mirek Zvolsky



On Thu, Mar 1, 2012 at 6:35 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I am pretty sure this works:
>
> Field('html', compute = lambda row: MARKMIN(row.markmin).xml()).
>
> I cannot reproduce the problem you refer mention.
>
> On Monday, 27 February 2012 04:10:23 UTC-6, Mirek Zvolský wrote:
>>
>> I think the behaviour of "compute=" is not good. Most people need
>>> calculated field which ALWAYS follow the source values and not just ONCE.
>>> So I have found in google group, lot of people fall through the time in
>>> same problem and there is still no clear solution.
>>>
>>> I now need this for Markmin source and calculated Html output (both
>>> fields in same table)
>>> I have solved this so:
>>> ...Field('html', compute = lambda row: MARKMIN(row.markmin).xml())...
>>> and in addition I use "onaccept" method in form:
>>> def post_forcecompute(form):
>>>     row = db.post(form.vars.id)
>>>     row.update_record(html=db.**post.html.compute(row))
>>> crud_post.settings.update_**onaccept = post_forcecompute
>>>
>>> This works, however it is not very good workaround, because it is
>>> neccessary to solve it in form, instead of in the model :(
>>>
>>> Mirek
>>>
>>

Reply via email to