Disclaimer: I may be wrong....
Reading your example code, you are updating a single record. 
If done in a single request, web2py wraps all commands in a transaction. 
In your code, that means that when you want to remove from photolist an 
item of your publication row, that operation is atomic. Why are you 
requesting that no other publication can be updated on that single request ?

On Tuesday, October 16, 2012 9:06:08 PM UTC+2, vince wrote:
>
> forget it. it's weird that read lock for mysql is read only, i have to 
> obtain write lock. it seems not possible to block write access only.
>
>  
>
> On Wednesday, October 17, 2012 2:55:49 AM UTC+8, vince wrote:
>>
>> i tried to lock table but with error
>> <class 'gluon.contrib.pymysql.err.InternalError'> (1099, u"Table 
>> 'publication' was locked with a READ lock and can't be updated")
>>
>>    db.executesql('LOCK TABLE publication READ;')
>>    result = db(db.publication.id==pubid).select()[0]
>>    newlist = result.photo_list
>>    newlist.remove(int(pid))
>>    db(db.publication.id==pubid).update(photo_list=newlist)
>>    db.executesql('UNLOCK TABLES;')
>>
>> is it possible to use the same connection?
>>
>> On Thursday, October 11, 2012 9:32:14 PM UTC+8, Massimo Di Pierro wrote:
>>>
>>> You can try:
>>>
>>> db.executesql('LOCK TABLE tablename READ;') 
>>>
>>>
>>> http://aarklondatabasetrivia.blogspot.com/2009/04/how-to-lock-and-unlock-tables-in-mysql.html
>>>
>>>
>>> On Thursday, 11 October 2012 01:44:14 UTC-5, vince wrote:
>>>>
>>>> can i lock a table as readonly during the transaction? the case is i 
>>>> need to insert a record to table B which is base on the query result of 
>>>> table A, i would like to lock table A as readonly until i finish the 
>>>> insert.
>>>>
>>>> i am using mysql at the moment. i know web2py may not have this 
>>>> feature, what is the best way to use mysql's 'lock table' on web2py?
>>>>
>>>> thanks in advance,
>>>> vince
>>>>
>>>

-- 



Reply via email to