lock table record

32 views
Skip to first unread message

Yebach

unread,
Nov 25, 2020, 4:40:37 AM11/25/20
to web2py-users
Hello,

how can I lock a record in a table (SQLform.grid) when somebody is editing one record so that other users cannot see it or it is grayed out or smth. 

Is there already an web2py ways or do I have to create a new filed set it as temp lock etc...

thank you

best regards.


AGRogers

unread,
Nov 25, 2020, 6:39:08 AM11/25/20
to web...@googlegroups.com
I am not aware that web2py has anything built in to do that. And it is a tricky task - to do it properly you need all sorts of real time feedback going to every grid that is already opened. It's conceptually not too hard for grids that will be opened in the future - just set a flag when someone starts to edit a record and clear it when they finish. But you would need to do that yourself.

One thing that makes this problem worse (ie one user overwriting another user's change) is that web2py writes *every* field in the form to the database even if the user only changed a single field. So even if two users edit two different fields of the same record, the last person to save the record will overwrite all fields with their data - the one they changed (good) and the ones they didnt change (bad)

___________________________
www.TenOutOfTen.org



--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/461d3292-f56d-4773-80c3-2926f3b6f079n%40googlegroups.com.

Vid Ogris

unread,
Nov 25, 2020, 6:50:34 AM11/25/20
to web...@googlegroups.com
Yeah I tried to do that... so I have records and there is a fields with 3 options as T (true),F (false),P(pending)

When the user starts to edit I set status to P and the SQLgrid does not list this record for other users (SELECT * From table where filed = 'F'). The problem is if the user click on the back button I cannot change the status back to F, so the record would be listed again.

Any ideas how to do that?

V V sre., 25. nov. 2020 ob 12:39 je oseba AGRogers <roge...@gmail.com> napisala:
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/r1Gy87kRcmE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CACWMBMNf34RWRJNm407G_O_PWqo1g2TdmcjX_9Ov%2B3_KeiHOuA%40mail.gmail.com.


--
Lep pozdrav 

Vid Ogris


AGRogers

unread,
Nov 25, 2020, 10:44:08 PM11/25/20
to web...@googlegroups.com
I use the code below to cleanup some stuff if the user leaves the page before doing some things i expected:

    window.onbeforeunload = function(){
        if (UnsavedCards > 0){CleanUpOnPageExit();}
    }

You could clear the flag at this point with an ajax call.
___________________________
www.TenOutOfTen.org

Reply all
Reply to author
Forward
0 new messages