[web2py] Re: Web2Py compute fields not working on update

2015-04-17 Thread Ian Ryder
Same problem here - all works fine but am using an after_update callback on 
a child record but the compute doesn't work when the parent record values 
are updated. 


On Tuesday, June 19, 2012 at 2:24:05 AM UTC+10, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
> ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_NOT_EMPTY()),
> Field('length', requires=IS_NOT_EMPTY()),
> Field('wide', requires=IS_NOT_EMPTY()),
> Field('for_sale', 'boolean', default=True),
> Field('beds', requires=IS_NOT_EMPTY()),
> Field('baths', requires=IS_NOT_EMPTY()),
> Field('fridge', 'boolean'),
> Field('stove', 'boolean'),
> Field('dishwasher', 'boolean'),
> Field('microwave', 'boolean'),
> Field('washer', 'boolean'),
> Field('dryer', 'boolean'),
> Field('photo1', 'upload'),
> Field('photo1_text'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo2_text'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo3_text'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo4_text'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo5_text'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('price',requires=IS_NOT_EMPTY()),
> Field('description', 'text', requires=IS_NOT_EMPTY()),
> Field('posted_on', 'datetime', readable=False, writable=False))
>
> db.define_table('state',
> Field('name'),
> Field('full_name'))
>
> db.define_table('wide',
> Field('type'),
> format='%(type)s')
>
>
> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
> (%(name)s)', zero=T('Select State'))
> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
> zero=T('Select Home Type'))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
> db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.home.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.home.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.home.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.home.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
>
>
> Here is my controller:
>
> def index():
> return locals()
> 
> def parks():
> if request.args(0):
> 

[web2py] Re: Web2Py compute fields not working on update

2015-01-18 Thread 黄祥
hi, 

i face the same problem, when trying to update the other table that have 
computed field with after_update callback.
e.g.
# after_update_purchase_header
def __after_update_purchase_header(s, f):
purchase = s.select().first()
# purchase_header
db(db.purchase_detail.purchase_no == purchase.id).update(grand_total = 
purchase.grand_total)

# on_define_purchase_header
def on_define_purchase_header(table): 
# callbacks
if not 'install' in request.controller :
# _after_update
table._after_update.append(__after_update_purchase_header)

# create table : purchase_header
db.define_table('purchase_header', 
Field('purchase_no'), 
Field('purchase_date', 'date'), 
Field('supplier', 'reference buyer_seller'), 
Field('payment_method', 'reference payment_method'), 
Field('notes', 'text'), 
Field('grand_total', 'integer'), 
on_define = on_define_purchase_header, 
format = '%(purchase_no)s')

# after_update_purchase_detail
def __after_update_purchase_detail(s, f):
purchase = s.select().first()
# product
db(db.product.id == purchase.product).update(capital = purchase.price)
# purchase_header
db(db.purchase_header.id == purchase.purchase_no).update(grand_total = 
purchase.grand_total)

# on_define_purchase_detail
def on_define_purchase_detail(table): 
# callbacks
if not 'install' in request.controller :
# _after_update
table._after_update.append(__after_update_purchase_detail)
# compute
table.total_price.compute = lambda r: r['quantity'] * r['price']

# create table : purchase_detail
db.define_table('purchase_detail', 
Field('purchase_no', 'reference purchase_header'), 
Field('product', 'reference product'), 
Field('quantity', 'integer'), 
Field('price', 'integer'), 
Field('total_price', 'integer'), 
Field('grand_total', 'integer'), 
on_define = on_define_purchase_detail, 
format = '%(purchase_no)s')

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.


[web2py] Re: Web2Py compute fields not working on update

2013-09-17 Thread Tim Richardson


On Wednesday, 18 September 2013 01:05:28 UTC+10, Anthony wrote:
>
> On Monday, September 16, 2013 9:07:35 PM UTC-4, Tim Richardson wrote:
>
>> The importance of definition order is in the book
>
>
> Where specifically? Are you talking about the fact that a computed field 
> can depend on a previously defined computed field (but not a computed field 
> that hasn't been defined yet)? 
>

Yes, this is what I meant & was my interpretation of the problem. 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Web2Py compute fields not working on update

2013-09-17 Thread Anthony
On Monday, September 16, 2013 9:07:35 PM UTC-4, Tim Richardson wrote:

> The importance of definition order is in the book


Where specifically? Are you talking about the fact that a computed field 
can depend on a previously defined computed field (but not a computed field 
that hasn't been defined yet)? Perhaps that's what Step meant -- I thought 
he meant that all fields required by a computed field must be defined 
before the computed field (which does not appear to be the case).

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Web2Py compute fields not working on update

2013-09-16 Thread Tim Richardson
The importance of definition order is in the book 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Web2Py compute fields not working on update

2013-09-15 Thread Anthony
On Sunday, September 15, 2013 10:27:51 AM UTC-4, step wrote:

> Sorry for resurrecting such an old thread, but I wanted to add my solution 
> to a very similar issue.
> It might seem obvious to expert web2py users; I found out that when some 
> compute fields weren't updating in my app it was due to unordered 
> cross-dependencies. In other words, if the computation of db.table.field_A 
> depends on the value of db.table.field_B, then db.define_table() must 
> define field_B *before* field_A, for any pair of field_A and field_B in 
> table, otherwise the computation of field_A will silently fail.
> Tested on version 2.6.1.
>

I cannot reproduce this -- can you show an example?

Anthony 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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: Web2Py compute fields not working on update

2013-09-15 Thread step
Sorry for resurrecting such an old thread, but I wanted to add my solution 
to a very similar issue.
It might seem obvious to expert web2py users; I found out that when some 
compute fields weren't updating in my app it was due to unordered 
cross-dependencies. In other words, if the computation of db.table.field_A 
depends on the value of db.table.field_B, then db.define_table() must 
define field_B *before* field_A, for any pair of field_A and field_B in 
table, otherwise the computation of field_A will silently fail.
Tested on version 2.6.1.


On Monday, June 18, 2012 6:24:05 PM UTC+2, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
> ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_NOT_EMPTY()),
> Field('length', requires=IS_NOT_EMPTY()),
> Field('wide', requires=IS_NOT_EMPTY()),
> Field('for_sale', 'boolean', default=True),
> Field('beds', requires=IS_NOT_EMPTY()),
> Field('baths', requires=IS_NOT_EMPTY()),
> Field('fridge', 'boolean'),
> Field('stove', 'boolean'),
> Field('dishwasher', 'boolean'),
> Field('microwave', 'boolean'),
> Field('washer', 'boolean'),
> Field('dryer', 'boolean'),
> Field('photo1', 'upload'),
> Field('photo1_text'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo2_text'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo3_text'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo4_text'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo5_text'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('price',requires=IS_NOT_EMPTY()),
> Field('description', 'text', requires=IS_NOT_EMPTY()),
> Field('posted_on', 'datetime', readable=False, writable=False))
>
> db.define_table('state',
> Field('name'),
> Field('full_name'))
>
> db.define_table('wide',
> Field('type'),
> format='%(type)s')
>
>
> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
> (%(name)s)', zero=T('Select State'))
> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
> zero=T('Select Home Type'))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
> db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.home.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.home.photo_thumb3.compu

[web2py] Re: Web2Py compute fields not working on update

2013-01-22 Thread palomar
sorry, I posted a new threat about it...
https://groups.google.com/forum/?fromgroups=#!topic/web2py/8RWkVAYVG1c
s.

Il giorno martedì 22 gennaio 2013 23:14:17 UTC+1, Massimo Di Pierro ha 
scritto:
>
> What web2py version? I cannot reproduce this.
>
> On Friday, 11 January 2013 14:13:04 UTC-6, palomar wrote:
>>
>> Sorry but I have the same problem; i tried with readable=true and 
>> writable=true and to comment the line in DAL.py, but nothing. 
>> I have this table:
>> db.define_table('magazzino',
>> Field('id_tipo', 'integer',default=0),
>> Field('p_p','double', default=0.0),
>> Field('pp_tot','double', writable=True, readable=True, compute=lambda 
>> r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1),
>> )
>> If I edit a row with a FORM the compute field works but if I edit it in a 
>> function with ajax don't...
>>
>> def modArtPrice():
>> newPp = 100
>> articolo = db.magazzino[request.vars.id]
>> articolo.update_record(p_p=newPp)  
>>
>> what's wrong?
>> s.
>>
>> Il giorno martedì 21 agosto 2012 18:35:05 UTC+2, Brandon Reynolds ha 
>> scritto:
>>>
>>> Thank you so much i got it working. I removed the readable=false and 
>>> writable=false and it works on update now.  Those are not needed anyway 
>>> because when the compute field is added on the model it hides it 
>>> automatically.
>>>
>>>
>>> Brandon
>>>
>>> On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote:

 If you look at issue 822 you will see an example of a thumb that works 
 on update. As the comments say, you have to not set writeable to false for 
 the thumb. If you do set writeable to false then compute only works on add 
 not edit or update.
 So my experience is that compute for images to create a thumb does work 
 on update.
 Peter

 On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:
>
> Has anyone found a way to fix this yet? Or is there a thumbnail module 
> out now? Like django's http://djangothumbnails.com/
>
> Brandon
>
>
> On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:
>>
>> I have this problem when i try to generate thumbnails. If the field 
>> is empty it inserts the photo thumb into the thumbnail. But when i try 
>> to 
>> update that record the thumbnail doesn't change. 
>>
>> Here is my model:
>>
>> # coding: utf8
>> from image import THUMBER
>>
>> db.define_table('park', 
>> Field('park_name', requires=IS_NOT_EMPTY()),
>> Field('park_city', requires=IS_NOT_EMPTY()),
>> Field('park_state', requires=IS_NOT_EMPTY()),
>> Field('park_address', requires=IS_NOT_EMPTY()),
>> Field('park_zip', requires=IS_NOT_EMPTY()),
>> Field('country', default="USA", notnull=True, readable=False, 
>> writable=False),
>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('park_phone_2', 'string', 
>> requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('manager', requires=IS_NOT_EMPTY()),
>> Field('manager_email', requires=IS_EMAIL()),
>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>> Field('vacant', 'integer'),
>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>> Field('water', 'boolean'),
>> Field('sewer', 'boolean'),
>> Field('trash', 'boolean'),
>> Field('pool', 'boolean'),
>> Field('playground', 'boolean'),
>> Field('clubhouse', 'boolean'),
>> Field('laundromat', 'boolean'),
>> Field('rv_spaces', 'boolean'),
>> Field('storage', 'boolean'),
>> Field('handicap_accessible', 'boolean'),
>> Field('community_description', 'text'),
>> format='%(park_name)s')
>>
>> db.define_table('home', 
>> Field('pid', notnull=True, readable=False, writable=False),
>> Field('lot'),
>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>> Field('make'),
>> Field('model'),
>> Field('width', requires=IS_NOT_EMPTY()),
>> Field('length', requires=IS_NOT_EMPTY()),
>> Field('wide', requires=IS_NOT_EMPTY()),
>> Field('for_sale', 'boolean', default=True),
>> Field('beds', requires=IS_NOT_EMPTY()),
>> Field('baths', requires=IS_NOT_EMPTY()),
>> Field('fridge', 'boolean'),
>> Field('stove', 'boolean'),
>> Field('dishwasher', 'boolean'),
>> Field('microwave', 'boolean'),

[web2py] Re: Web2Py compute fields not working on update

2013-01-22 Thread Massimo Di Pierro
What web2py version? I cannot reproduce this.

On Friday, 11 January 2013 14:13:04 UTC-6, palomar wrote:
>
> Sorry but I have the same problem; i tried with readable=true and 
> writable=true and to comment the line in DAL.py, but nothing. 
> I have this table:
> db.define_table('magazzino',
> Field('id_tipo', 'integer',default=0),
> Field('p_p','double', default=0.0),
> Field('pp_tot','double', writable=True, readable=True, compute=lambda 
> r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1),
> )
> If I edit a row with a FORM the compute field works but if I edit it in a 
> function with ajax don't...
>
> def modArtPrice():
> newPp = 100
> articolo = db.magazzino[request.vars.id]
> articolo.update_record(p_p=newPp)  
>
> what's wrong?
> s.
>
> Il giorno martedì 21 agosto 2012 18:35:05 UTC+2, Brandon Reynolds ha 
> scritto:
>>
>> Thank you so much i got it working. I removed the readable=false and 
>> writable=false and it works on update now.  Those are not needed anyway 
>> because when the compute field is added on the model it hides it 
>> automatically.
>>
>>
>> Brandon
>>
>> On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote:
>>>
>>> If you look at issue 822 you will see an example of a thumb that works 
>>> on update. As the comments say, you have to not set writeable to false for 
>>> the thumb. If you do set writeable to false then compute only works on add 
>>> not edit or update.
>>> So my experience is that compute for images to create a thumb does work 
>>> on update.
>>> Peter
>>>
>>> On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:

 Has anyone found a way to fix this yet? Or is there a thumbnail module 
 out now? Like django's http://djangothumbnails.com/

 Brandon


 On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', 
> requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_NOT_EMPTY()),
> Field('length', requires=IS_NOT_EMPTY()),
> Field('wide', requires=IS_NOT_EMPTY()),
> Field('for_sale', 'boolean', default=True),
> Field('beds', requires=IS_NOT_EMPTY()),
> Field('baths', requires=IS_NOT_EMPTY()),
> Field('fridge', 'boolean'),
> Field('stove', 'boolean'),
> Field('dishwasher', 'boolean'),
> Field('microwave', 'boolean'),
> Field('washer', 'boolean'),
> Field('dryer', 'boolean'),
> Field('photo1', 'upload'),
> Field('photo1_text'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo2_text'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>

[web2py] Re: Web2Py compute fields not working on update

2013-01-11 Thread palomar
Sorry but I have the same problem; i tried with readable=true and 
writable=true and to uncomment the line in DAL.py, but nothing. 
I have this table:
db.define_table('magazzino',
Field('id_tipo', 'integer',default=0),
Field('p_p','double', default=0.0),
Field('pp_tot','double', writable=True, readable=True, compute=lambda 
r: r['id_tipo']==0 and r['p_p']*1 or r['p_p']*r['id_tipo']*-1),
)
If I edit a row with a FORM the compute field works but if I edit it in a 
function with ajax don't...

def modArtPrice():
newPp = 100
articolo = db.magazzino[request.vars.id]
articolo.update_record(p_p=newPp)  

what's wrong?
s.

Il giorno martedì 21 agosto 2012 18:35:05 UTC+2, Brandon Reynolds ha 
scritto:
>
> Thank you so much i got it working. I removed the readable=false and 
> writable=false and it works on update now.  Those are not needed anyway 
> because when the compute field is added on the model it hides it 
> automatically.
>
>
> Brandon
>
> On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote:
>>
>> If you look at issue 822 you will see an example of a thumb that works on 
>> update. As the comments say, you have to not set writeable to false for the 
>> thumb. If you do set writeable to false then compute only works on add not 
>> edit or update.
>> So my experience is that compute for images to create a thumb does work 
>> on update.
>> Peter
>>
>> On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:
>>>
>>> Has anyone found a way to fix this yet? Or is there a thumbnail module 
>>> out now? Like django's http://djangothumbnails.com/
>>>
>>> Brandon
>>>
>>>
>>> On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:

 I have this problem when i try to generate thumbnails. If the field is 
 empty it inserts the photo thumb into the thumbnail. But when i try to 
 update that record the thumbnail doesn't change. 

 Here is my model:

 # coding: utf8
 from image import THUMBER

 db.define_table('park', 
 Field('park_name', requires=IS_NOT_EMPTY()),
 Field('park_city', requires=IS_NOT_EMPTY()),
 Field('park_state', requires=IS_NOT_EMPTY()),
 Field('park_address', requires=IS_NOT_EMPTY()),
 Field('park_zip', requires=IS_NOT_EMPTY()),
 Field('country', default="USA", notnull=True, readable=False, 
 writable=False),
 Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
 Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('park_phone_2', 'string', 
 requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('photo1', 'upload'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 Field('photo_thumb5', 'upload', readable=False, writable=False),
 Field('manager', requires=IS_NOT_EMPTY()),
 Field('manager_email', requires=IS_EMAIL()),
 Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
 Field('vacant', 'integer'),
 Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
 Field('water', 'boolean'),
 Field('sewer', 'boolean'),
 Field('trash', 'boolean'),
 Field('pool', 'boolean'),
 Field('playground', 'boolean'),
 Field('clubhouse', 'boolean'),
 Field('laundromat', 'boolean'),
 Field('rv_spaces', 'boolean'),
 Field('storage', 'boolean'),
 Field('handicap_accessible', 'boolean'),
 Field('community_description', 'text'),
 format='%(park_name)s')

 db.define_table('home', 
 Field('pid', notnull=True, readable=False, writable=False),
 Field('lot'),
 Field('year', length=4, requires=IS_NOT_EMPTY()),
 Field('make'),
 Field('model'),
 Field('width', requires=IS_NOT_EMPTY()),
 Field('length', requires=IS_NOT_EMPTY()),
 Field('wide', requires=IS_NOT_EMPTY()),
 Field('for_sale', 'boolean', default=True),
 Field('beds', requires=IS_NOT_EMPTY()),
 Field('baths', requires=IS_NOT_EMPTY()),
 Field('fridge', 'boolean'),
 Field('stove', 'boolean'),
 Field('dishwasher', 'boolean'),
 Field('microwave', 'boolean'),
 Field('washer', 'boolean'),
 Field('dryer', 'boolean'),
 Field('photo1', 'upload'),
 Field('photo1_text'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo2_text'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo3_text'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo4_text'),
 Field('photo_thumb4', 'upload', readable=False, writable=

[web2py] Re: Web2Py compute fields not working on update

2012-08-21 Thread Brandon Reynolds
Thank you so much i got it working. I removed the readable=false and 
writable=false and it works on update now.  Those are not needed anyway 
because when the compute field is added on the model it hides it 
automatically.


Brandon

On Thursday, August 9, 2012 2:14:42 PM UTC-6, Deidre wrote:
>
> If you look at issue 822 you will see an example of a thumb that works on 
> update. As the comments say, you have to not set writeable to false for the 
> thumb. If you do set writeable to false then compute only works on add not 
> edit or update.
> So my experience is that compute for images to create a thumb does work on 
> update.
> Peter
>
> On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:
>>
>> Has anyone found a way to fix this yet? Or is there a thumbnail module 
>> out now? Like django's http://djangothumbnails.com/
>>
>> Brandon
>>
>>
>> On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:
>>>
>>> I have this problem when i try to generate thumbnails. If the field is 
>>> empty it inserts the photo thumb into the thumbnail. But when i try to 
>>> update that record the thumbnail doesn't change. 
>>>
>>> Here is my model:
>>>
>>> # coding: utf8
>>> from image import THUMBER
>>>
>>> db.define_table('park', 
>>> Field('park_name', requires=IS_NOT_EMPTY()),
>>> Field('park_city', requires=IS_NOT_EMPTY()),
>>> Field('park_state', requires=IS_NOT_EMPTY()),
>>> Field('park_address', requires=IS_NOT_EMPTY()),
>>> Field('park_zip', requires=IS_NOT_EMPTY()),
>>> Field('country', default="USA", notnull=True, readable=False, 
>>> writable=False),
>>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>>> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
>>> ]+'))),
>>> Field('photo1', 'upload'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>>> Field('photo2', 'upload'),
>>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>> Field('photo3', 'upload'),
>>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>>> Field('photo4', 'upload'),
>>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>>> Field('photo5', 'upload'),
>>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>>> Field('manager', requires=IS_NOT_EMPTY()),
>>> Field('manager_email', requires=IS_EMAIL()),
>>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>>> Field('vacant', 'integer'),
>>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>>> Field('water', 'boolean'),
>>> Field('sewer', 'boolean'),
>>> Field('trash', 'boolean'),
>>> Field('pool', 'boolean'),
>>> Field('playground', 'boolean'),
>>> Field('clubhouse', 'boolean'),
>>> Field('laundromat', 'boolean'),
>>> Field('rv_spaces', 'boolean'),
>>> Field('storage', 'boolean'),
>>> Field('handicap_accessible', 'boolean'),
>>> Field('community_description', 'text'),
>>> format='%(park_name)s')
>>>
>>> db.define_table('home', 
>>> Field('pid', notnull=True, readable=False, writable=False),
>>> Field('lot'),
>>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>>> Field('make'),
>>> Field('model'),
>>> Field('width', requires=IS_NOT_EMPTY()),
>>> Field('length', requires=IS_NOT_EMPTY()),
>>> Field('wide', requires=IS_NOT_EMPTY()),
>>> Field('for_sale', 'boolean', default=True),
>>> Field('beds', requires=IS_NOT_EMPTY()),
>>> Field('baths', requires=IS_NOT_EMPTY()),
>>> Field('fridge', 'boolean'),
>>> Field('stove', 'boolean'),
>>> Field('dishwasher', 'boolean'),
>>> Field('microwave', 'boolean'),
>>> Field('washer', 'boolean'),
>>> Field('dryer', 'boolean'),
>>> Field('photo1', 'upload'),
>>> Field('photo1_text'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>>> Field('photo2', 'upload'),
>>> Field('photo2_text'),
>>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>> Field('photo3', 'upload'),
>>> Field('photo3_text'),
>>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>>> Field('photo4', 'upload'),
>>> Field('photo4_text'),
>>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>>> Field('photo5', 'upload'),
>>> Field('photo5_text'),
>>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>>> Field('price',requires=IS_NOT_EMPTY()),
>>> Field('description', 'text', requires=IS_NOT_EMPTY()),
>>> Field('posted_on', 'datetime', readable=False, writable=False))
>>>
>>> db.define_table('state',
>>> Field('name'),
>>> Field('full_name'))
>>>
>>> db.define_table('wide',
>>> Field('type'),
>>> format='%(type)s')
>>>
>>>
>>> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
>>> (%(name)s)', zero=T('Select State'))
>>> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
>>> zero=T('Select Home Type'))
>>>
>>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>>> "photo_thumb1", 144, 115)
>>> db.park.photo_thumb2.compute = lambda row: THUMBER(row.phot

[web2py] Re: Web2Py compute fields not working on update

2012-08-09 Thread Deidre
If you look at issue 822 you will see an example of a thumb that works on 
update. As the comments say, you have to not set writeable to false for the 
thumb. If you do set writeable to false then compute only works on add not 
edit or update.
So my experience is that compute for images to create a thumb does work on 
update.
Peter

On Thursday, August 9, 2012 5:04:28 PM UTC+1, Brandon Reynolds wrote:
>
> Has anyone found a way to fix this yet? Or is there a thumbnail module out 
> now? Like django's http://djangothumbnails.com/
>
> Brandon
>
>
> On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:
>>
>> I have this problem when i try to generate thumbnails. If the field is 
>> empty it inserts the photo thumb into the thumbnail. But when i try to 
>> update that record the thumbnail doesn't change. 
>>
>> Here is my model:
>>
>> # coding: utf8
>> from image import THUMBER
>>
>> db.define_table('park', 
>> Field('park_name', requires=IS_NOT_EMPTY()),
>> Field('park_city', requires=IS_NOT_EMPTY()),
>> Field('park_state', requires=IS_NOT_EMPTY()),
>> Field('park_address', requires=IS_NOT_EMPTY()),
>> Field('park_zip', requires=IS_NOT_EMPTY()),
>> Field('country', default="USA", notnull=True, readable=False, 
>> writable=False),
>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
>> ]+'))),
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('manager', requires=IS_NOT_EMPTY()),
>> Field('manager_email', requires=IS_EMAIL()),
>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>> Field('vacant', 'integer'),
>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>> Field('water', 'boolean'),
>> Field('sewer', 'boolean'),
>> Field('trash', 'boolean'),
>> Field('pool', 'boolean'),
>> Field('playground', 'boolean'),
>> Field('clubhouse', 'boolean'),
>> Field('laundromat', 'boolean'),
>> Field('rv_spaces', 'boolean'),
>> Field('storage', 'boolean'),
>> Field('handicap_accessible', 'boolean'),
>> Field('community_description', 'text'),
>> format='%(park_name)s')
>>
>> db.define_table('home', 
>> Field('pid', notnull=True, readable=False, writable=False),
>> Field('lot'),
>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>> Field('make'),
>> Field('model'),
>> Field('width', requires=IS_NOT_EMPTY()),
>> Field('length', requires=IS_NOT_EMPTY()),
>> Field('wide', requires=IS_NOT_EMPTY()),
>> Field('for_sale', 'boolean', default=True),
>> Field('beds', requires=IS_NOT_EMPTY()),
>> Field('baths', requires=IS_NOT_EMPTY()),
>> Field('fridge', 'boolean'),
>> Field('stove', 'boolean'),
>> Field('dishwasher', 'boolean'),
>> Field('microwave', 'boolean'),
>> Field('washer', 'boolean'),
>> Field('dryer', 'boolean'),
>> Field('photo1', 'upload'),
>> Field('photo1_text'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo2_text'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo3_text'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo4_text'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo5_text'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('price',requires=IS_NOT_EMPTY()),
>> Field('description', 'text', requires=IS_NOT_EMPTY()),
>> Field('posted_on', 'datetime', readable=False, writable=False))
>>
>> db.define_table('state',
>> Field('name'),
>> Field('full_name'))
>>
>> db.define_table('wide',
>> Field('type'),
>> format='%(type)s')
>>
>>
>> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
>> (%(name)s)', zero=T('Select State'))
>> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
>> zero=T('Select Home Type'))
>>
>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>> "photo_thumb1", 144, 115)
>> db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
>> "photo_thumb2", 144, 115)
>> db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
>> "photo_thumb3", 144, 115)
>> db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
>> "photo_thumb4", 144, 115)
>> db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
>> "photo_thumb5", 144, 115)
>> db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>> "photo_thumb1", 144, 115)
>> db.ho

[web2py] Re: Web2Py compute fields not working on update

2012-08-09 Thread Brandon Reynolds
Has anyone found a way to fix this yet? Or is there a thumbnail module out 
now? Like django's http://djangothumbnails.com/

Brandon


On Monday, June 18, 2012 10:24:05 AM UTC-6, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
> ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_NOT_EMPTY()),
> Field('length', requires=IS_NOT_EMPTY()),
> Field('wide', requires=IS_NOT_EMPTY()),
> Field('for_sale', 'boolean', default=True),
> Field('beds', requires=IS_NOT_EMPTY()),
> Field('baths', requires=IS_NOT_EMPTY()),
> Field('fridge', 'boolean'),
> Field('stove', 'boolean'),
> Field('dishwasher', 'boolean'),
> Field('microwave', 'boolean'),
> Field('washer', 'boolean'),
> Field('dryer', 'boolean'),
> Field('photo1', 'upload'),
> Field('photo1_text'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo2_text'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo3_text'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo4_text'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo5_text'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('price',requires=IS_NOT_EMPTY()),
> Field('description', 'text', requires=IS_NOT_EMPTY()),
> Field('posted_on', 'datetime', readable=False, writable=False))
>
> db.define_table('state',
> Field('name'),
> Field('full_name'))
>
> db.define_table('wide',
> Field('type'),
> format='%(type)s')
>
>
> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
> (%(name)s)', zero=T('Select State'))
> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
> zero=T('Select Home Type'))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
> db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.home.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.home.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.home.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.home.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
>
>
> Here is my controller:
>
> def index():
> return locals()
> 
> def parks():
> if request.args(0):
> parks = 
> db(db.park.park_state==req

[web2py] Re: Web2Py compute fields not working on update

2012-06-29 Thread web2py_Superfan
as a workaround in my update statement, I updated the computed field to be 
the computed field via 

mint_order = 
db(db.mint_orders2.id==coin.deannas_dough.mint_orders_id).select(db.mint_orders2.ALL)[0]
db(db.mint_orders2.id==mint_order.id).update(num_won=num_won+1,image_thumb=mint_order.image_thumb)

On Friday, June 29, 2012 5:01:24 PM UTC-7, web2py_Superfan wrote:
>
> I have a much older build, and I have this issue as well.  The compute 
> field gives me an error when I do an update, 'key error' image
>
> On Wednesday, June 20, 2012 9:08:31 PM UTC-7, Brandon Reynolds wrote:
>>
>> If i am not the only one not having i think it's possible it may be a 
>> web2py bug. I bet it is only a bug in update fields as i have seem some 
>> other complaints online. I have filed a bug ticket. Hopefully it is fixed 
>> soon. I am only a beginner programmer so i still am learning debugging and 
>> how python and web2py function. I am more than happy to try and help get 
>> this fixed.
>>
>> I appreciate the helpfulness of everyone in this group and the web2py 
>> devs. You guys rock and i am glad i chose web2py over it's alternatives. I 
>> never got this much help when i was writing php!
>>
>> Thanks Again,
>> Brandon
>>
>> On Wednesday, June 20, 2012 4:15:46 PM UTC-6, pbreit wrote:
>>>
>>> Oh, my bad. You're right, looks like not updating. Will dig in more. 
>>> Sorry about that.
>>
>>

[web2py] Re: Web2Py compute fields not working on update

2012-06-29 Thread web2py_Superfan
I have a much older build, and I have this issue as well.  The compute 
field gives me an error when I do an update, 'key error' image

On Wednesday, June 20, 2012 9:08:31 PM UTC-7, Brandon Reynolds wrote:
>
> If i am not the only one not having i think it's possible it may be a 
> web2py bug. I bet it is only a bug in update fields as i have seem some 
> other complaints online. I have filed a bug ticket. Hopefully it is fixed 
> soon. I am only a beginner programmer so i still am learning debugging and 
> how python and web2py function. I am more than happy to try and help get 
> this fixed.
>
> I appreciate the helpfulness of everyone in this group and the web2py 
> devs. You guys rock and i am glad i chose web2py over it's alternatives. I 
> never got this much help when i was writing php!
>
> Thanks Again,
> Brandon
>
> On Wednesday, June 20, 2012 4:15:46 PM UTC-6, pbreit wrote:
>>
>> Oh, my bad. You're right, looks like not updating. Will dig in more. 
>> Sorry about that.
>
>

[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread Brandon Reynolds
If i am not the only one not having i think it's possible it may be a 
web2py bug. I bet it is only a bug in update fields as i have seem some 
other complaints online. I have filed a bug ticket. Hopefully it is fixed 
soon. I am only a beginner programmer so i still am learning debugging and 
how python and web2py function. I am more than happy to try and help get 
this fixed.

I appreciate the helpfulness of everyone in this group and the web2py devs. 
You guys rock and i am glad i chose web2py over it's alternatives. I never 
got this much help when i was writing php!

Thanks Again,
Brandon

On Wednesday, June 20, 2012 4:15:46 PM UTC-6, pbreit wrote:
>
> Oh, my bad. You're right, looks like not updating. Will dig in more. Sorry 
> about that.

-- 





[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread pbreit
Oh, my bad. You're right, looks like not updating. Will dig in more. Sorry 
about that.

[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread Brandon Reynolds
pbreit,

I just used your script and my first time thumbnails are working again. 
However the are still not computing on update. Do your thumbnails compute 
when updating?

Brandon

On Wednesday, June 20, 2012 1:58:12 PM UTC-6, pbreit wrote:
>
> Mine seems to work OK with current trunk:
>
> db.item.image_thumb.compute = lambda r: resize_image(r['image'], 
> (150,130), 'thumb')
>
> def resize_image(image, size, path, rotate=0):
> if image:
> try:
> img = Image.open('%sstatic/uploads/%s' % (request.folder, 
> image))
> img = img.convert("RGB")
> img.thumbnail(size, Image.ANTIALIAS)
> img = img.rotate(rotate)
> root, ext = os.path.splitext(image)
> filename = '%s_%s%s' %(root, path, ext)
> img.save('%sstatic/uploads/%s' % (request.folder, filename))
> return filename
> except Exception, e:
> return e
> else:
> return None
>


[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread pbreit
Mine seems to work OK with current trunk:

db.item.image_thumb.compute = lambda r: resize_image(r['image'], (150,130), 
'thumb')

def resize_image(image, size, path, rotate=0):
if image:
try:
img = Image.open('%sstatic/uploads/%s' % (request.folder, 
image))
img = img.convert("RGB")
img.thumbnail(size, Image.ANTIALIAS)
img = img.rotate(rotate)
root, ext = os.path.splitext(image)
filename = '%s_%s%s' %(root, path, ext)
img.save('%sstatic/uploads/%s' % (request.folder, filename))
return filename
except Exception, e:
return e
else:
return None


[web2py] Re: Web2Py compute fields not working on update

2012-06-20 Thread Brandon Reynolds
You are correct. I am still sort of new to python and i didn't realize that 
.thumbnail was a PIL method. However after i fixed that issue it still 
isn't working at all. Does anyone have a simple script to do thumbnails? 
Maybe one that doesn't involve compute. 

Brandon


On Tuesday, June 19, 2012 5:16:03 PM UTC-6, villas wrote:
>
> I don't understand this line:
>
> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>
> why isn't it this??
>
> img.thumbnail((nx, ny), Image.ANTIALIAS)
>
> Isn't thumbnail a method in PIL?   Maybe I'm missing something?
>
> Regards,
> David
>
>
>

[web2py] Re: Web2Py compute fields not working on update

2012-06-19 Thread villas
I don't understand this line:

img.db_photo_var((nx, ny), Image.ANTIALIAS)

why isn't it this??

img.thumbnail((nx, ny), Image.ANTIALIAS)

Isn't thumbnail a method in PIL?   Maybe I'm missing something?

Regards,
David




[web2py] Re: Web2Py compute fields not working on update

2012-06-19 Thread Brandon Reynolds
I have spend a long time on this and haven't come up with a fix. My script 
is back to the original but oddly enough not the new record thumbnails 
aren't generating either. I had the files when they were working saved 
elsewhere and just put them back in. Now thumbnails aren't generating at 
all. Does anyone know of a way to generate thumbnails easily without the 
compute function? Does web2py have a built in tool that i missed? Maybe 
would be a good feature to add on like inside an "IS_THUMB(size)" function.

Thanks for all the help,
Brandon

On Tuesday, June 19, 2012 9:59:15 AM UTC-6, Massimo Di Pierro wrote:
>
> Basically the function _listify is called by both inser and update. It 
> figures out which fields are missing and gets their default, update or 
> computed value.  Looks like it is not calling compute. It has three loops:
>
> for name in fields:
>...
> for ofield in self:
>...
> for ofield in self:
> if not ofield.name in new_fields_names and ofield.compute:
>  ...
> Can you figure out why the "if not ofield.name in new_fields_names and 
> ofield.compute" is false for your field?
>
>
> On Tuesday, 19 June 2012 10:43:59 UTC-5, Brandon Reynolds wrote:
>>
>> Peter,
>>
>> I tried your fix with no luck. It did not work unfortunately.
>>
>> Massimo,
>>
>> I replaced the lines you specified with no luck. It never printed out 
>> computing. What should we try to next to debug this?
>>
>> Brandon
>>
>> On Tuesday, June 19, 2012 8:28:20 AM UTC-6, Massimo Di Pierro wrote:
>>>
>>> I need your help debugging this. In dal.py there are these lines:
>>>
>>> def _listify(self,fields,update=False):
>>> for ofield in self:
>>> if not ofield.name in new_fields_names and ofield.compute:
>>> try:
>>> 
>>> new_fields.append((ofield,ofield.compute(Row(fields
>>> except KeyError:
>>> pass
>>>
>>> The line new_fields.append((ofield,ofield.compute(Row(fields should 
>>> always be called (insert and update). Can you try remove the try... 
>>> except.. 
>>>
>>> def _listify(self,fields,update=False):
>>> for ofield in self:
>>> if not ofield.name in new_fields_names and ofield.compute:
>>> #try:
>>> print 'computing',ofield.name
>>> 
>>> new_fields.append((ofield,ofield.compute(Row(fields
>>> #except KeyError:
>>> #   pass
>>>
>>> and see what you get?
>>>
>>>
>>> On Tuesday, 19 June 2012 08:35:19 UTC-5, LightDot wrote:

 I think this is closely connected to an existing Issue 687 (Compute= 
 should work always, not once):

 http://code.google.com/p/web2py/issues/detail?id=687

 Regards

 On Monday, June 18, 2012 11:21:57 PM UTC+2, peter wrote:
>
> I would try removing the readable and writeable false for the compute 
> fields. It seems that it does automatically not show them. I found that 
> setting readable and writeable to False means the thumbs only get 
> computed 
> on insert, not update. I reported this a while back. 
> Peter
>
> On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:
>>
>> Will look into this asap. Please open a ticket about it so that it is 
>> tracked.
>>
>>
>> On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>>>
>>> In a new record a thumbnail is correctly generated from photo. But 
>>> if I didn't upload a photo or want to change the photo the thumbnail 
>>> doesn't generate. So basically a new record works properly but when 
>>> updating nothing in the thumbnail changes at all whether or not is 
>>> currently has a photo in it. 
>>>
>>> 
>>> model:
>>>
>>> from image import THUMBER
>>> db.define_table('park', 
>>> Field('photo1', 'upload'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False))
>>>
>>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>>> "photo_thumb1", 144, 115)
>>>
>>> 
>>> image.py:
>>>
>>> from gluon import current
>>>  
>>> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
>>> if image:
>>> try:
>>> request = current.request
>>> from PIL import Image
>>> import os
>>> img = Image.open(request.folder + 'uploads/' + image)
>>> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>>> root, ext = os.path.splitext(image)
>>> thumb = '%s_%s%s' % (root, name, ext)
>>> img.save(request.folder + 'uploads/' + thumb)
>>> return thumb
>>> except Exception:
>>>

[web2py] Re: Web2Py compute fields not working on update

2012-06-19 Thread Massimo Di Pierro
Basically the function _listify is called by both inser and update. It 
figures out which fields are missing and gets their default, update or 
computed value.  Looks like it is not calling compute. It has three loops:

for name in fields:
   ...
for ofield in self:
   ...
for ofield in self:
if not ofield.name in new_fields_names and ofield.compute:
 ...
Can you figure out why the "if not ofield.name in new_fields_names and 
ofield.compute" is false for your field?


On Tuesday, 19 June 2012 10:43:59 UTC-5, Brandon Reynolds wrote:
>
> Peter,
>
> I tried your fix with no luck. It did not work unfortunately.
>
> Massimo,
>
> I replaced the lines you specified with no luck. It never printed out 
> computing. What should we try to next to debug this?
>
> Brandon
>
> On Tuesday, June 19, 2012 8:28:20 AM UTC-6, Massimo Di Pierro wrote:
>>
>> I need your help debugging this. In dal.py there are these lines:
>>
>> def _listify(self,fields,update=False):
>> for ofield in self:
>> if not ofield.name in new_fields_names and ofield.compute:
>> try:
>> 
>> new_fields.append((ofield,ofield.compute(Row(fields
>> except KeyError:
>> pass
>>
>> The line new_fields.append((ofield,ofield.compute(Row(fields should 
>> always be called (insert and update). Can you try remove the try... 
>> except.. 
>>
>> def _listify(self,fields,update=False):
>> for ofield in self:
>> if not ofield.name in new_fields_names and ofield.compute:
>> #try:
>> print 'computing',ofield.name
>> 
>> new_fields.append((ofield,ofield.compute(Row(fields
>> #except KeyError:
>> #   pass
>>
>> and see what you get?
>>
>>
>> On Tuesday, 19 June 2012 08:35:19 UTC-5, LightDot wrote:
>>>
>>> I think this is closely connected to an existing Issue 687 (Compute= 
>>> should work always, not once):
>>>
>>> http://code.google.com/p/web2py/issues/detail?id=687
>>>
>>> Regards
>>>
>>> On Monday, June 18, 2012 11:21:57 PM UTC+2, peter wrote:

 I would try removing the readable and writeable false for the compute 
 fields. It seems that it does automatically not show them. I found that 
 setting readable and writeable to False means the thumbs only get computed 
 on insert, not update. I reported this a while back. 
 Peter

 On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:
>
> Will look into this asap. Please open a ticket about it so that it is 
> tracked.
>
>
> On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>>
>> In a new record a thumbnail is correctly generated from photo. But if 
>> I didn't upload a photo or want to change the photo the thumbnail 
>> doesn't 
>> generate. So basically a new record works properly but when updating 
>> nothing in the thumbnail changes at all whether or not is currently has 
>> a 
>> photo in it. 
>>
>> 
>> model:
>>
>> from image import THUMBER
>> db.define_table('park', 
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False))
>>
>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>> "photo_thumb1", 144, 115)
>>
>> 
>> image.py:
>>
>> from gluon import current
>>  
>> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
>> if image:
>> try:
>> request = current.request
>> from PIL import Image
>> import os
>> img = Image.open(request.folder + 'uploads/' + image)
>> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>> root, ext = os.path.splitext(image)
>> thumb = '%s_%s%s' % (root, name, ext)
>> img.save(request.folder + 'uploads/' + thumb)
>> return thumb
>> except Exception:
>> return image
>>
>>
>>
>> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> Let me understand this better.
>>>
>>> on insert, the thumbnails are created.
>>> on update, if you upload a new photo1 is photo_thing1 generated? 
>>>
>>> Can you provide a simpler code to reproduce the problem with a just 
>>> one upload field and one thumbnail field?
>>>
>>> massimo
>>>
>>>
>>>
>>>
>>> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:

 I have this problem when i try to generate thumbnails. If the field 
 is empty it inserts the photo thumb into the thumbnail. But when i try 
 to 

[web2py] Re: Web2Py compute fields not working on update

2012-06-19 Thread Brandon Reynolds
Peter,

I tried your fix with no luck. It did not work unfortunately.

Massimo,

I replaced the lines you specified with no luck. It never printed out 
computing. What should we try to next to debug this?

Brandon

On Tuesday, June 19, 2012 8:28:20 AM UTC-6, Massimo Di Pierro wrote:
>
> I need your help debugging this. In dal.py there are these lines:
>
> def _listify(self,fields,update=False):
> for ofield in self:
> if not ofield.name in new_fields_names and ofield.compute:
> try:
> new_fields.append((ofield,ofield.compute(Row(fields
> except KeyError:
> pass
>
> The line new_fields.append((ofield,ofield.compute(Row(fields should 
> always be called (insert and update). Can you try remove the try... 
> except.. 
>
> def _listify(self,fields,update=False):
> for ofield in self:
> if not ofield.name in new_fields_names and ofield.compute:
> #try:
> print 'computing',ofield.name
> new_fields.append((ofield,ofield.compute(Row(fields
> #except KeyError:
> #   pass
>
> and see what you get?
>
>
> On Tuesday, 19 June 2012 08:35:19 UTC-5, LightDot wrote:
>>
>> I think this is closely connected to an existing Issue 687 (Compute= 
>> should work always, not once):
>>
>> http://code.google.com/p/web2py/issues/detail?id=687
>>
>> Regards
>>
>> On Monday, June 18, 2012 11:21:57 PM UTC+2, peter wrote:
>>>
>>> I would try removing the readable and writeable false for the compute 
>>> fields. It seems that it does automatically not show them. I found that 
>>> setting readable and writeable to False means the thumbs only get computed 
>>> on insert, not update. I reported this a while back. 
>>> Peter
>>>
>>> On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:

 Will look into this asap. Please open a ticket about it so that it is 
 tracked.


 On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>
> In a new record a thumbnail is correctly generated from photo. But if 
> I didn't upload a photo or want to change the photo the thumbnail doesn't 
> generate. So basically a new record works properly but when updating 
> nothing in the thumbnail changes at all whether or not is currently has a 
> photo in it. 
>
> 
> model:
>
> from image import THUMBER
> db.define_table('park', 
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
>
> 
> image.py:
>
> from gluon import current
>  
> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
> if image:
> try:
> request = current.request
> from PIL import Image
> import os
> img = Image.open(request.folder + 'uploads/' + image)
> img.db_photo_var((nx, ny), Image.ANTIALIAS)
> root, ext = os.path.splitext(image)
> thumb = '%s_%s%s' % (root, name, ext)
> img.save(request.folder + 'uploads/' + thumb)
> return thumb
> except Exception:
> return image
>
>
>
> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>>
>> Let me understand this better.
>>
>> on insert, the thumbnails are created.
>> on update, if you upload a new photo1 is photo_thing1 generated? 
>>
>> Can you provide a simpler code to reproduce the problem with a just 
>> one upload field and one thumbnail field?
>>
>> massimo
>>
>>
>>
>>
>> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>>>
>>> I have this problem when i try to generate thumbnails. If the field 
>>> is empty it inserts the photo thumb into the thumbnail. But when i try 
>>> to 
>>> update that record the thumbnail doesn't change. 
>>>
>>> Here is my model:
>>>
>>> # coding: utf8
>>> from image import THUMBER
>>>
>>> db.define_table('park', 
>>> Field('park_name', requires=IS_NOT_EMPTY()),
>>> Field('park_city', requires=IS_NOT_EMPTY()),
>>> Field('park_state', requires=IS_NOT_EMPTY()),
>>> Field('park_address', requires=IS_NOT_EMPTY()),
>>> Field('park_zip', requires=IS_NOT_EMPTY()),
>>> Field('country', default="USA", notnull=True, readable=False, 
>>> writable=False),
>>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>>> Field('park_phone_2', 'string', 
>>> requires=IS_EMPT

[web2py] Re: Web2Py compute fields not working on update

2012-06-19 Thread Massimo Di Pierro
I need your help debugging this. In dal.py there are these lines:

def _listify(self,fields,update=False):
for ofield in self:
if not ofield.name in new_fields_names and ofield.compute:
try:
new_fields.append((ofield,ofield.compute(Row(fields
except KeyError:
pass

The line new_fields.append((ofield,ofield.compute(Row(fields should 
always be called (insert and update). Can you try remove the try... 
except.. 

def _listify(self,fields,update=False):
for ofield in self:
if not ofield.name in new_fields_names and ofield.compute:
#try:
print 'computing',ofield.name
new_fields.append((ofield,ofield.compute(Row(fields
#except KeyError:
#   pass

and see what you get?


On Tuesday, 19 June 2012 08:35:19 UTC-5, LightDot wrote:
>
> I think this is closely connected to an existing Issue 687 (Compute= 
> should work always, not once):
>
> http://code.google.com/p/web2py/issues/detail?id=687
>
> Regards
>
> On Monday, June 18, 2012 11:21:57 PM UTC+2, peter wrote:
>>
>> I would try removing the readable and writeable false for the compute 
>> fields. It seems that it does automatically not show them. I found that 
>> setting readable and writeable to False means the thumbs only get computed 
>> on insert, not update. I reported this a while back. 
>> Peter
>>
>> On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:
>>>
>>> Will look into this asap. Please open a ticket about it so that it is 
>>> tracked.
>>>
>>>
>>> On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:

 In a new record a thumbnail is correctly generated from photo. But if I 
 didn't upload a photo or want to change the photo the thumbnail doesn't 
 generate. So basically a new record works properly but when updating 
 nothing in the thumbnail changes at all whether or not is currently has a 
 photo in it. 

 
 model:

 from image import THUMBER
 db.define_table('park', 
 Field('photo1', 'upload'),
 Field('photo_thumb1', 'upload', readable=False, writable=False))

 db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
 "photo_thumb1", 144, 115)

 
 image.py:

 from gluon import current
  
 def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
 if image:
 try:
 request = current.request
 from PIL import Image
 import os
 img = Image.open(request.folder + 'uploads/' + image)
 img.db_photo_var((nx, ny), Image.ANTIALIAS)
 root, ext = os.path.splitext(image)
 thumb = '%s_%s%s' % (root, name, ext)
 img.save(request.folder + 'uploads/' + thumb)
 return thumb
 except Exception:
 return image



 On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>
> Let me understand this better.
>
> on insert, the thumbnails are created.
> on update, if you upload a new photo1 is photo_thing1 generated? 
>
> Can you provide a simpler code to reproduce the problem with a just 
> one upload field and one thumbnail field?
>
> massimo
>
>
>
>
> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>>
>> I have this problem when i try to generate thumbnails. If the field 
>> is empty it inserts the photo thumb into the thumbnail. But when i try 
>> to 
>> update that record the thumbnail doesn't change. 
>>
>> Here is my model:
>>
>> # coding: utf8
>> from image import THUMBER
>>
>> db.define_table('park', 
>> Field('park_name', requires=IS_NOT_EMPTY()),
>> Field('park_city', requires=IS_NOT_EMPTY()),
>> Field('park_state', requires=IS_NOT_EMPTY()),
>> Field('park_address', requires=IS_NOT_EMPTY()),
>> Field('park_zip', requires=IS_NOT_EMPTY()),
>> Field('country', default="USA", notnull=True, readable=False, 
>> writable=False),
>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('park_phone_2', 'string', 
>> requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo_thumb4', 'upload', readable=Fal

[web2py] Re: Web2Py compute fields not working on update

2012-06-19 Thread LightDot
I think this is closely connected to an existing Issue 687 (Compute= should 
work always, not once):

http://code.google.com/p/web2py/issues/detail?id=687

Regards

On Monday, June 18, 2012 11:21:57 PM UTC+2, peter wrote:
>
> I would try removing the readable and writeable false for the compute 
> fields. It seems that it does automatically not show them. I found that 
> setting readable and writeable to False means the thumbs only get computed 
> on insert, not update. I reported this a while back. 
> Peter
>
> On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:
>>
>> Will look into this asap. Please open a ticket about it so that it is 
>> tracked.
>>
>>
>> On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>>>
>>> In a new record a thumbnail is correctly generated from photo. But if I 
>>> didn't upload a photo or want to change the photo the thumbnail doesn't 
>>> generate. So basically a new record works properly but when updating 
>>> nothing in the thumbnail changes at all whether or not is currently has a 
>>> photo in it. 
>>>
>>> 
>>> model:
>>>
>>> from image import THUMBER
>>> db.define_table('park', 
>>> Field('photo1', 'upload'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False))
>>>
>>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>>> "photo_thumb1", 144, 115)
>>>
>>> 
>>> image.py:
>>>
>>> from gluon import current
>>>  
>>> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
>>> if image:
>>> try:
>>> request = current.request
>>> from PIL import Image
>>> import os
>>> img = Image.open(request.folder + 'uploads/' + image)
>>> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>>> root, ext = os.path.splitext(image)
>>> thumb = '%s_%s%s' % (root, name, ext)
>>> img.save(request.folder + 'uploads/' + thumb)
>>> return thumb
>>> except Exception:
>>> return image
>>>
>>>
>>>
>>> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:

 Let me understand this better.

 on insert, the thumbnails are created.
 on update, if you upload a new photo1 is photo_thing1 generated? 

 Can you provide a simpler code to reproduce the problem with a just one 
 upload field and one thumbnail field?

 massimo




 On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', 
> requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_N

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread peter
I would try removing the readable and writeable false for the compute 
fields. It seems that it does automatically not show them. I found that 
setting readable and writeable to False means the thumbs only get computed 
on insert, not update. I reported this a while back. 
Peter

On Monday, 18 June 2012 22:14:09 UTC+1, Massimo Di Pierro wrote:
>
> Will look into this asap. Please open a ticket about it so that it is 
> tracked.
>
>
> On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>>
>> In a new record a thumbnail is correctly generated from photo. But if I 
>> didn't upload a photo or want to change the photo the thumbnail doesn't 
>> generate. So basically a new record works properly but when updating 
>> nothing in the thumbnail changes at all whether or not is currently has a 
>> photo in it. 
>>
>> 
>> model:
>>
>> from image import THUMBER
>> db.define_table('park', 
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False))
>>
>> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
>> "photo_thumb1", 144, 115)
>>
>> 
>> image.py:
>>
>> from gluon import current
>>  
>> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
>> if image:
>> try:
>> request = current.request
>> from PIL import Image
>> import os
>> img = Image.open(request.folder + 'uploads/' + image)
>> img.db_photo_var((nx, ny), Image.ANTIALIAS)
>> root, ext = os.path.splitext(image)
>> thumb = '%s_%s%s' % (root, name, ext)
>> img.save(request.folder + 'uploads/' + thumb)
>> return thumb
>> except Exception:
>> return image
>>
>>
>>
>> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>>>
>>> Let me understand this better.
>>>
>>> on insert, the thumbnails are created.
>>> on update, if you upload a new photo1 is photo_thing1 generated? 
>>>
>>> Can you provide a simpler code to reproduce the problem with a just one 
>>> upload field and one thumbnail field?
>>>
>>> massimo
>>>
>>>
>>>
>>>
>>> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:

 I have this problem when i try to generate thumbnails. If the field is 
 empty it inserts the photo thumb into the thumbnail. But when i try to 
 update that record the thumbnail doesn't change. 

 Here is my model:

 # coding: utf8
 from image import THUMBER

 db.define_table('park', 
 Field('park_name', requires=IS_NOT_EMPTY()),
 Field('park_city', requires=IS_NOT_EMPTY()),
 Field('park_state', requires=IS_NOT_EMPTY()),
 Field('park_address', requires=IS_NOT_EMPTY()),
 Field('park_zip', requires=IS_NOT_EMPTY()),
 Field('country', default="USA", notnull=True, readable=False, 
 writable=False),
 Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
 Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('park_phone_2', 'string', 
 requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
 Field('photo1', 'upload'),
 Field('photo_thumb1', 'upload', readable=False, writable=False),
 Field('photo2', 'upload'),
 Field('photo_thumb2', 'upload', readable=False, writable=False),
 Field('photo3', 'upload'),
 Field('photo_thumb3', 'upload', readable=False, writable=False),
 Field('photo4', 'upload'),
 Field('photo_thumb4', 'upload', readable=False, writable=False),
 Field('photo5', 'upload'),
 Field('photo_thumb5', 'upload', readable=False, writable=False),
 Field('manager', requires=IS_NOT_EMPTY()),
 Field('manager_email', requires=IS_EMAIL()),
 Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
 Field('vacant', 'integer'),
 Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
 Field('water', 'boolean'),
 Field('sewer', 'boolean'),
 Field('trash', 'boolean'),
 Field('pool', 'boolean'),
 Field('playground', 'boolean'),
 Field('clubhouse', 'boolean'),
 Field('laundromat', 'boolean'),
 Field('rv_spaces', 'boolean'),
 Field('storage', 'boolean'),
 Field('handicap_accessible', 'boolean'),
 Field('community_description', 'text'),
 format='%(park_name)s')

 db.define_table('home', 
 Field('pid', notnull=True, readable=False, writable=False),
 Field('lot'),
 Field('year', length=4, requires=IS_NOT_EMPTY()),
 Field('make'),
 Field('model'),
 Field('width', requires=IS_NOT_EMPTY()),
 Field('length', requires=IS_NOT_EMPTY()),
 Field('wide', requires=IS_NOT_EMPTY()),
 Field('for_sale', 'boolean', default=True),
 Field('beds', requires=IS_NOT_EMPTY()),
 Field('baths', requires=IS_NOT_EMPTY()),
 Field('fridge', 'boolean'),
 Field('stove', 'boolean'),
 Field('dishwasher', 'boolean'),
 Fiel

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread Massimo Di Pierro
Will look into this asap. Please open a ticket about it so that it is 
tracked.


On Monday, 18 June 2012 14:40:30 UTC-5, Brandon Reynolds wrote:
>
> In a new record a thumbnail is correctly generated from photo. But if I 
> didn't upload a photo or want to change the photo the thumbnail doesn't 
> generate. So basically a new record works properly but when updating 
> nothing in the thumbnail changes at all whether or not is currently has a 
> photo in it. 
>
> 
> model:
>
> from image import THUMBER
> db.define_table('park', 
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
>
> 
> image.py:
>
> from gluon import current
>  
> def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
> if image:
> try:
> request = current.request
> from PIL import Image
> import os
> img = Image.open(request.folder + 'uploads/' + image)
> img.db_photo_var((nx, ny), Image.ANTIALIAS)
> root, ext = os.path.splitext(image)
> thumb = '%s_%s%s' % (root, name, ext)
> img.save(request.folder + 'uploads/' + thumb)
> return thumb
> except Exception:
> return image
>
>
>
> On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>>
>> Let me understand this better.
>>
>> on insert, the thumbnails are created.
>> on update, if you upload a new photo1 is photo_thing1 generated? 
>>
>> Can you provide a simpler code to reproduce the problem with a just one 
>> upload field and one thumbnail field?
>>
>> massimo
>>
>>
>>
>>
>> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>>>
>>> I have this problem when i try to generate thumbnails. If the field is 
>>> empty it inserts the photo thumb into the thumbnail. But when i try to 
>>> update that record the thumbnail doesn't change. 
>>>
>>> Here is my model:
>>>
>>> # coding: utf8
>>> from image import THUMBER
>>>
>>> db.define_table('park', 
>>> Field('park_name', requires=IS_NOT_EMPTY()),
>>> Field('park_city', requires=IS_NOT_EMPTY()),
>>> Field('park_state', requires=IS_NOT_EMPTY()),
>>> Field('park_address', requires=IS_NOT_EMPTY()),
>>> Field('park_zip', requires=IS_NOT_EMPTY()),
>>> Field('country', default="USA", notnull=True, readable=False, 
>>> writable=False),
>>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>>> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
>>> ]+'))),
>>> Field('photo1', 'upload'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>>> Field('photo2', 'upload'),
>>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>> Field('photo3', 'upload'),
>>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>>> Field('photo4', 'upload'),
>>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>>> Field('photo5', 'upload'),
>>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>>> Field('manager', requires=IS_NOT_EMPTY()),
>>> Field('manager_email', requires=IS_EMAIL()),
>>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>>> Field('vacant', 'integer'),
>>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>>> Field('water', 'boolean'),
>>> Field('sewer', 'boolean'),
>>> Field('trash', 'boolean'),
>>> Field('pool', 'boolean'),
>>> Field('playground', 'boolean'),
>>> Field('clubhouse', 'boolean'),
>>> Field('laundromat', 'boolean'),
>>> Field('rv_spaces', 'boolean'),
>>> Field('storage', 'boolean'),
>>> Field('handicap_accessible', 'boolean'),
>>> Field('community_description', 'text'),
>>> format='%(park_name)s')
>>>
>>> db.define_table('home', 
>>> Field('pid', notnull=True, readable=False, writable=False),
>>> Field('lot'),
>>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>>> Field('make'),
>>> Field('model'),
>>> Field('width', requires=IS_NOT_EMPTY()),
>>> Field('length', requires=IS_NOT_EMPTY()),
>>> Field('wide', requires=IS_NOT_EMPTY()),
>>> Field('for_sale', 'boolean', default=True),
>>> Field('beds', requires=IS_NOT_EMPTY()),
>>> Field('baths', requires=IS_NOT_EMPTY()),
>>> Field('fridge', 'boolean'),
>>> Field('stove', 'boolean'),
>>> Field('dishwasher', 'boolean'),
>>> Field('microwave', 'boolean'),
>>> Field('washer', 'boolean'),
>>> Field('dryer', 'boolean'),
>>> Field('photo1', 'upload'),
>>> Field('photo1_text'),
>>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>>> Field('photo2', 'upload'),
>>> Field('photo2_text'),
>>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>>> Field('photo3', 'upload'),
>>> Field('photo3_text'),
>>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>>> Field(

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread Brandon Reynolds
In a new record a thumbnail is correctly generated from photo. But if I 
didn't upload a photo or want to change the photo the thumbnail doesn't 
generate. So basically a new record works properly but when updating 
nothing in the thumbnail changes at all whether or not is currently has a 
photo in it. 


model:

from image import THUMBER
db.define_table('park', 
Field('photo1', 'upload'),
Field('photo_thumb1', 'upload', readable=False, writable=False))

db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
"photo_thumb1", 144, 115)


image.py:

from gluon import current
 
def THUMBER(image, db_photo_var, nx=120, ny=120, name='thumb'):
if image:
try:
request = current.request
from PIL import Image
import os
img = Image.open(request.folder + 'uploads/' + image)
img.db_photo_var((nx, ny), Image.ANTIALIAS)
root, ext = os.path.splitext(image)
thumb = '%s_%s%s' % (root, name, ext)
img.save(request.folder + 'uploads/' + thumb)
return thumb
except Exception:
return image
   


On Monday, June 18, 2012 1:17:07 PM UTC-6, Massimo Di Pierro wrote:
>
> Let me understand this better.
>
> on insert, the thumbnails are created.
> on update, if you upload a new photo1 is photo_thing1 generated? 
>
> Can you provide a simpler code to reproduce the problem with a just one 
> upload field and one thumbnail field?
>
> massimo
>
>
>
>
> On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>>
>> I have this problem when i try to generate thumbnails. If the field is 
>> empty it inserts the photo thumb into the thumbnail. But when i try to 
>> update that record the thumbnail doesn't change. 
>>
>> Here is my model:
>>
>> # coding: utf8
>> from image import THUMBER
>>
>> db.define_table('park', 
>> Field('park_name', requires=IS_NOT_EMPTY()),
>> Field('park_city', requires=IS_NOT_EMPTY()),
>> Field('park_state', requires=IS_NOT_EMPTY()),
>> Field('park_address', requires=IS_NOT_EMPTY()),
>> Field('park_zip', requires=IS_NOT_EMPTY()),
>> Field('country', default="USA", notnull=True, readable=False, 
>> writable=False),
>> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
>> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
>> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
>> ]+'))),
>> Field('photo1', 'upload'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('manager', requires=IS_NOT_EMPTY()),
>> Field('manager_email', requires=IS_EMAIL()),
>> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
>> Field('vacant', 'integer'),
>> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
>> Field('water', 'boolean'),
>> Field('sewer', 'boolean'),
>> Field('trash', 'boolean'),
>> Field('pool', 'boolean'),
>> Field('playground', 'boolean'),
>> Field('clubhouse', 'boolean'),
>> Field('laundromat', 'boolean'),
>> Field('rv_spaces', 'boolean'),
>> Field('storage', 'boolean'),
>> Field('handicap_accessible', 'boolean'),
>> Field('community_description', 'text'),
>> format='%(park_name)s')
>>
>> db.define_table('home', 
>> Field('pid', notnull=True, readable=False, writable=False),
>> Field('lot'),
>> Field('year', length=4, requires=IS_NOT_EMPTY()),
>> Field('make'),
>> Field('model'),
>> Field('width', requires=IS_NOT_EMPTY()),
>> Field('length', requires=IS_NOT_EMPTY()),
>> Field('wide', requires=IS_NOT_EMPTY()),
>> Field('for_sale', 'boolean', default=True),
>> Field('beds', requires=IS_NOT_EMPTY()),
>> Field('baths', requires=IS_NOT_EMPTY()),
>> Field('fridge', 'boolean'),
>> Field('stove', 'boolean'),
>> Field('dishwasher', 'boolean'),
>> Field('microwave', 'boolean'),
>> Field('washer', 'boolean'),
>> Field('dryer', 'boolean'),
>> Field('photo1', 'upload'),
>> Field('photo1_text'),
>> Field('photo_thumb1', 'upload', readable=False, writable=False),
>> Field('photo2', 'upload'),
>> Field('photo2_text'),
>> Field('photo_thumb2', 'upload', readable=False, writable=False),
>> Field('photo3', 'upload'),
>> Field('photo3_text'),
>> Field('photo_thumb3', 'upload', readable=False, writable=False),
>> Field('photo4', 'upload'),
>> Field('photo4_text'),
>> Field('photo_thumb4', 'upload', readable=False, writable=False),
>> Field('photo5', 'upload'),
>> Field('photo5_text'),
>> Field('photo_thumb5', 'upload', readable=False, writable=False),
>> Field('price',requires=IS_NOT_EMPTY()),
>> Field('description', 'text', re

[web2py] Re: Web2Py compute fields not working on update

2012-06-18 Thread Massimo Di Pierro
Let me understand this better.

on insert, the thumbnails are created.
on update, if you upload a new photo1 is photo_thing1 generated? 

Can you provide a simpler code to reproduce the problem with a just one 
upload field and one thumbnail field?

massimo




On Monday, 18 June 2012 11:24:05 UTC-5, Brandon Reynolds wrote:
>
> I have this problem when i try to generate thumbnails. If the field is 
> empty it inserts the photo thumb into the thumbnail. But when i try to 
> update that record the thumbnail doesn't change. 
>
> Here is my model:
>
> # coding: utf8
> from image import THUMBER
>
> db.define_table('park', 
> Field('park_name', requires=IS_NOT_EMPTY()),
> Field('park_city', requires=IS_NOT_EMPTY()),
> Field('park_state', requires=IS_NOT_EMPTY()),
> Field('park_address', requires=IS_NOT_EMPTY()),
> Field('park_zip', requires=IS_NOT_EMPTY()),
> Field('country', default="USA", notnull=True, readable=False, 
> writable=False),
> Field('park_phone', requires=IS_MATCH('[\d\-\(\) ]+')),
> Field('park_fax', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) ]+'))),
> Field('park_phone_2', 'string', requires=IS_EMPTY_OR(IS_MATCH('[\d\-\(\) 
> ]+'))),
> Field('photo1', 'upload'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('manager', requires=IS_NOT_EMPTY()),
> Field('manager_email', requires=IS_EMAIL()),
> Field('spaces', 'integer', requires=IS_NOT_EMPTY()),
> Field('vacant', 'integer'),
> Field('lot_rent', 'integer', requires=IS_NOT_EMPTY()),
> Field('water', 'boolean'),
> Field('sewer', 'boolean'),
> Field('trash', 'boolean'),
> Field('pool', 'boolean'),
> Field('playground', 'boolean'),
> Field('clubhouse', 'boolean'),
> Field('laundromat', 'boolean'),
> Field('rv_spaces', 'boolean'),
> Field('storage', 'boolean'),
> Field('handicap_accessible', 'boolean'),
> Field('community_description', 'text'),
> format='%(park_name)s')
>
> db.define_table('home', 
> Field('pid', notnull=True, readable=False, writable=False),
> Field('lot'),
> Field('year', length=4, requires=IS_NOT_EMPTY()),
> Field('make'),
> Field('model'),
> Field('width', requires=IS_NOT_EMPTY()),
> Field('length', requires=IS_NOT_EMPTY()),
> Field('wide', requires=IS_NOT_EMPTY()),
> Field('for_sale', 'boolean', default=True),
> Field('beds', requires=IS_NOT_EMPTY()),
> Field('baths', requires=IS_NOT_EMPTY()),
> Field('fridge', 'boolean'),
> Field('stove', 'boolean'),
> Field('dishwasher', 'boolean'),
> Field('microwave', 'boolean'),
> Field('washer', 'boolean'),
> Field('dryer', 'boolean'),
> Field('photo1', 'upload'),
> Field('photo1_text'),
> Field('photo_thumb1', 'upload', readable=False, writable=False),
> Field('photo2', 'upload'),
> Field('photo2_text'),
> Field('photo_thumb2', 'upload', readable=False, writable=False),
> Field('photo3', 'upload'),
> Field('photo3_text'),
> Field('photo_thumb3', 'upload', readable=False, writable=False),
> Field('photo4', 'upload'),
> Field('photo4_text'),
> Field('photo_thumb4', 'upload', readable=False, writable=False),
> Field('photo5', 'upload'),
> Field('photo5_text'),
> Field('photo_thumb5', 'upload', readable=False, writable=False),
> Field('price',requires=IS_NOT_EMPTY()),
> Field('description', 'text', requires=IS_NOT_EMPTY()),
> Field('posted_on', 'datetime', readable=False, writable=False))
>
> db.define_table('state',
> Field('name'),
> Field('full_name'))
>
> db.define_table('wide',
> Field('type'),
> format='%(type)s')
>
>
> db.park.park_state.requires = IS_IN_DB(db, 'state.name', '%(full_name)s 
> (%(name)s)', zero=T('Select State'))
> db.home.wide.requires = IS_IN_DB(db, 'wide.type', '%(type)s', 
> zero=T('Select Home Type'))
>
> db.park.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.park.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.park.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.park.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.park.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
> db.home.photo_thumb1.compute = lambda row: THUMBER(row.photo1, 
> "photo_thumb1", 144, 115)
> db.home.photo_thumb2.compute = lambda row: THUMBER(row.photo2, 
> "photo_thumb2", 144, 115)
> db.home.photo_thumb3.compute = lambda row: THUMBER(row.photo3, 
> "photo_thumb3", 144, 115)
> db.home.photo_thumb4.compute = lambda row: THUMBER(row.photo4, 
> "photo_thumb4", 144, 115)
> db.home.photo_thumb5.compute = lambda row: THUMBER(row.photo5, 
> "photo_thumb5", 144, 115)
>
>
> Here is my controller:
>
> def ind