you're basically asking for a select ... for update, that isn't supported 
on many backends. Asking for it in SQLite means locking THE ENTIRE table .

usually you'd mimick what you want (without hurting performances so much) 
with an additional field.


db(db.table.id == x).update(hidden=True)
db.commit()
rec = db.table(x)

and then

rec.anotherfield = f(rec.field)
rec.hidden = False
rec.update_record()
db.commit()
#or
db(db.table.id == x).update(anotherfield=f(rec.field), hidden=False)
db.commit()


On Wednesday, April 1, 2015 at 12:27:34 AM UTC+2, Val K wrote:
>
> Hi!
> Here is controller's logic:
> 1. Get field value:                     
>   fld_v= db.table[i].any_field
>
> 2. Evaluate new value depending on existing one:               
>    new_fld_v=fun(fld_v)
>
> 3. Update record with new value: 
>    db(db.table.id==i).update(any_field=new_fld_v)
>
> The problem:
> After first step (i.e. after SELECT)  just a SHARED lock is acquired (see 
> SQLite docs).  Thus, any other request can call the same controller and get 
> the same field's value and etc.
> How can I allow sequential calls only to prevent any other's SELECT until 
> UPDATE? I know about BEGIN DEFERRED/IMMEDIATE/EXCLUSIVE, also
> I know web2py enclose all request/controller's calls in something like 
> BEGIN/COMMIT, but  SQLite doesn't support nested BEGIN/COMMIT (except 
> SAVEPOINT).
> What is default isolation_level/locking_mode is realized during web2py 
> request process?
> Is there safe solution or I worry for nothing?
>
>
>

-- 
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