[web2py] Re: Computed field not computed at INSERT ?

2014-12-23 Thread Mirek Zvolský
I am sorry, today I have found that this was my mistake. I have string values from SQLFORM - and compute evaluates properly. But I have different FORM for bulk insert of many records, where in form.process().accepted I have integer values: compute in DAL is wrapper into try/except - and it

[web2py] Re: Computed field not computed at INSERT ?

2014-12-19 Thread Anthony
Please show your code. On Friday, December 19, 2014 6:13:02 AM UTC-5, Mirek Zvolský wrote: 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

[web2py] Re: computed field and reference

2013-05-29 Thread Matteo Luperto
I've deleted the testing db and started with a new one and now it works for me too. I've tried add a new record to problemsHere but it gave me an unexpected error (the DAL expected an unique field in language and language is no longer an unique field), so probably the issue was somewhere else.

[web2py] Re: computed field and reference

2013-05-27 Thread Niphlod
I can't replicate the issue you're having. That syntax works. Check again your code BTW: it's quite a strange model. you want the language to be unique in the first table. In the second one you reference the first table (that is unique by definition) with a non unique reference, but then

[web2py] Re: Computed field date difference as integer

2013-05-19 Thread Alan Etkin
I like to store the difference as integer not char(512) I guess the output of the compute function is a timedelta object (since you are operating with date objects), which has a .days attribute. You can use the .days attribute instead: compute=lambda r: (r['end_date']-r['begin_date']).days

[web2py] Re: Computed field date difference as integer

2013-05-19 Thread Zsolt Szabó
Thanks a lot! 2013. május 19., vasárnap 17:20:45 UTC+2 időpontban Alan Etkin a következőt írta: I like to store the difference as integer not char(512) I guess the output of the compute function is a timedelta object (since you are operating with date objects), which has a .days

[web2py] Re: Computed field does not get updated when creating database entry

2012-08-22 Thread Johann Spies
Hallo Daniel,I have defined a database table which has some fields which must be computed: Field('password', 'password', length=512, compute=automatic_password,readable =False, label='Password'), The functions create_new_agent and automatic_password are part of my libraries. They

[web2py] Re: Computed field does not get updated when creating database entry

2012-08-22 Thread Johann Spies
On Wednesday, 22 August 2012 15:28:50 UTC+2, Johann Spies wrote: Hallo Daniel,I have defined a database table which has some fields which must be computed: Field('password', 'password', length=512, compute=automatic_password,readable =False, label='Password'), The functions

[web2py] Re: Computed field does not get updated when creating database entry

2012-08-22 Thread Anthony
Field('password', 'password', length=512, compute=automatic_password,readable =False, label='Password'), The functions create_new_agent and automatic_password are part of my libraries. They are returning the expected types (strings in both cases) If you search the book for

[web2py] Re: Computed field does not get updated when creating database entry

2012-08-22 Thread Daniel Gonzalez
Thanks guys, After all your comments I have found the problem: my agent database was defined *twice* in my models, one time with computed fields, the final time without them. I was getting very strange behavior and was quite confused - understandably. I have removed the phoney definition,

[web2py] Re: Computed field does not get updated when creating database entry

2012-08-22 Thread Anthony
And now a small explanation of why I did not notice this at first: I had a define_table in a testing.py controller. I have removed this controller from my development repo, but since I am rsyncing to the web2py applications directory, that old testing.py controller was still in the

[web2py] Re: Computed field does not get updated when creating database entry

2012-08-22 Thread Daniel Gonzalez
e ... i meant testing.py *model* On Wednesday, August 22, 2012 6:53:52 PM UTC+2, Anthony wrote: And now a small explanation of why I did not notice this at first: I had a define_table in a testing.py controller. I have removed this controller from my development repo, but since I am

[web2py] Re: computed field

2012-04-21 Thread Annet
Thank you both for your replies. I'll give your solutions a try and see which one best suits my needs. Kind regards, Annet

[web2py] Re: computed field

2012-04-20 Thread pbreit
I'd probably use a function or virtual field for that, not store it in DB. And it could be cleaned up a bit. Something like: def trunc_desc(s) if len(s) 128: return s[:128] + '...' return s

[web2py] Re: Computed field

2011-12-22 Thread Jose Carlos Junior
Dont workedthe field dont show in form Sorry...any ideas ?? On 21 Dez, 22:05, Jose Carlos Junior josec...@gmail.com wrote:  Thank you Jim .i gonna try this as soon as possibleand return... On 21 dez, 18:21, Jim Steil j...@qlf.com wrote: Here's what I would try:

[web2py] Re: Computed field

2011-12-22 Thread Jose Carlos Junior
Sorry it worked.i made a mistake Thank you Jim On 22 Dez, 09:46, Jose Carlos Junior josec...@gmail.com wrote: Dont workedthe field dont show in form Sorry...any ideas ?? On 21 Dez, 22:05, Jose Carlos Junior josec...@gmail.com wrote:  Thank you Jim .i gonna

Re: [web2py] Re: Computed field

2011-12-22 Thread Jim Steil
thanks for the update, good to hear you got it working. -Jim On 12/22/2011 6:13 AM, Jose Carlos Junior wrote: Sorry it worked.i made a mistake Thank you Jim On 22 Dez, 09:46, Jose Carlos Juniorjosec...@gmail.com wrote: Dont workedthe field dont show in form

[web2py] Re: Computed field

2011-12-21 Thread Jose Carlos Junior
Thank you Jim .i gonna try this as soon as possibleand return... On 21 dez, 18:21, Jim Steil j...@qlf.com wrote: 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

[web2py] Re: computed field or is_in_db(query...

2011-12-20 Thread Jose Carlos Junior
Solved..Thanks alot... dear Richard Vézina On 19 dez, 21:42, Jose Carlos Junior josec...@gmail.com wrote: Good idea...    I gonna try thisas soon as possible Thanks alot... On 19 dez, 17:44, Richard Vézina ml.richard.vez...@gmail.com wrote: Carlos, If you really not

Re: [web2py] Re: computed field or is_in_db(query...

2011-12-20 Thread Richard Vézina
Your welcome :) Richard On Tue, Dec 20, 2011 at 1:15 PM, Jose Carlos Junior josec...@gmail.comwrote: Solved..Thanks alot... dear Richard Vézina On 19 dez, 21:42, Jose Carlos Junior josec...@gmail.com wrote: Good idea... I gonna try thisas soon as possible Thanks alot...

[web2py] Re: computed field or is_in_db(query...

2011-12-19 Thread Jose Carlos Junior
OK but i need to call from gtils_representante table the nm_cidadao from cidadao tablethis is my doubt gtils_representante is a n:n relationship between GTIL(not posted) and representante. I believe I have not explained it right the first time...

Re: [web2py] Re: computed field or is_in_db(query...

2011-12-19 Thread Richard Vézina
What about that : db.tab2(db.tab1(id).id).field ?? Richard On Mon, Dec 19, 2011 at 11:42 AM, Jose Carlos Junior josec...@gmail.comwrote: OK but i need to call from gtils_representante table the nm_cidadao from cidadao tablethis is my doubt gtils_representante is a n:n

Re: [web2py] Re: computed field or is_in_db(query...

2011-12-19 Thread Richard Vézina
Carlos, If you really not getting it... Here what I am doing to work around the kind of problem you seem to have... I would make a view at backend level with id and reprensent I want for this particular id, then I write db model for the view like if it was a web2py table and then use this table

[web2py] Re: computed field or is_in_db(query...

2011-12-19 Thread Jose Carlos Junior
Good idea... I gonna try thisas soon as possible Thanks alot... On 19 dez, 17:44, Richard Vézina ml.richard.vez...@gmail.com wrote: Carlos, If you really not getting it... Here what I am doing to work around the kind of problem you seem to have... I would make a view at backend

[web2py] Re: computed field: update and images

2011-11-29 Thread pbreit
I'd be curious as well. That looks like my resize_image function. For now I've just been letting old images clutter up. Somehow you'd need to know the original filename to be able to delete it either in the resize_image function or perhaps a second computed function.