On Thursday, January 12, 2017 at 7:53:05 AM UTC-8, lyn2py wrote:
>
> Well... after taking time out to write the entire story... my mistake.
>

The first step in code reviews is publishing the code   :-)  Does a lot to 
clarify the mind!

 Glad you found the issue and got it sorted, and thanks for reporting back.

/dps


> In define_tables > Field, I assigned it (a long time ago) as "string" 
> instead of "integer". So the comparison was switched around, because it was 
> comparing a single digit, e.g. 5, to a double digit number, like 15. It's 
> all fixed per the web2py book when I enforced "int()". Grrrrr..... 
>
> On Thursday, January 12, 2017 at 11:35:12 PM UTC+8, lyn2py wrote:
>>
>> Hi guys, I just wanted to confirm this.
>>
>> The web2py book (link = 
>> http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#callbacks-on-record-insert-delete-and-update)
>>  
>> says:
>> "The return values of these callback should be None or False. If any of 
>> the _before_* callback returns a True value it will abort the actual 
>> insert/update/delete operation."
>>
>> But my experience differs, I am comparing the value in db ("query set") 
>> and the value I am about to insert ("fields"). 
>> CRITERION: If the "query set" is a smaller value, abort the update 
>> operation.
>> So, per the instruction in the web2py book, I made it like so:
>> db.table._before_update.append(lambda s,f: qs(number)<f['number'])
>>
>> which means the "query set" is smaller than the "fields", then, it's 
>> TRUE, so, abort update. 
>>
>> But it didn't work until I switched the operator sign to make the 
>> statement FALSE, like so:
>> db.table._before_update.append(lambda s,f: qs(number)>f['number'])
>>
>> which means the "query set" is NOT smaller than the "fields". It would 
>> abort update. 
>>
>> Am I confused about something or does the web2py book need an edit/update?
>>
>> Thank you for reading!
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to