Skip to content

Commit

Permalink
Merge pull request #808 from LukeTapekhin/heavy_refactor
Browse files Browse the repository at this point in the history
locks on tables without primary keys
  • Loading branch information
LukeTapekhin authored Sep 5, 2017
2 parents 97d67e9 + e095173 commit 0b7851a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lingvodoc/views/v2/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ def view_dictionary_roles(request): # tested & in docs

@view_config(route_name='dictionary_roles', renderer='json', request_method='POST', permission='create')
def edit_dictionary_roles(request): # tested & in docs
DBSession.execute("LOCK TABLE user_to_group_association IN EXCLUSIVE MODE;")
DBSession.execute("LOCK TABLE organization_to_group_association IN EXCLUSIVE MODE;")
response = dict()
client_id = request.matchdict.get('client_id')
object_id = request.matchdict.get('object_id')
Expand Down
1 change: 1 addition & 0 deletions lingvodoc/views/v2/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def view_organization(request): # TODO: test
@view_config(route_name='organization', renderer='json', request_method='PUT')
def edit_organization(request): # TODO: test
try:
DBSession.execute("LOCK TABLE user_to_organization_association IN EXCLUSIVE MODE;")
response = dict()
organization_id = request.matchdict.get('organization_id')
organization = DBSession.query(Organization).filter_by(id=organization_id).first()
Expand Down
2 changes: 2 additions & 0 deletions lingvodoc/views/v2/perspective/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,8 @@ def view_perspective_roles(request): # TODO: test

@view_config(route_name='perspective_roles', renderer='json', request_method='POST', permission='create')
def edit_perspective_roles(request):
DBSession.execute("LOCK TABLE user_to_group_association IN EXCLUSIVE MODE;")
DBSession.execute("LOCK TABLE organization_to_group_association IN EXCLUSIVE MODE;")
response = dict()
client_id = request.matchdict.get('perspective_client_id')
object_id = request.matchdict.get('perspective_object_id')
Expand Down
1 change: 1 addition & 0 deletions lingvodoc/views/v2/userrequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def accept_userrequest(request):
# group.users.append(admin)

elif userrequest.type == 'participate_org':
DBSession.execute("LOCK TABLE user_to_organization_association IN EXCLUSIVE MODE;")
org_id = userrequest.subject['org_id']
user_id = userrequest.subject['user_id']
organization = DBSession.query(Organization).filter_by(id=org_id).first()
Expand Down

0 comments on commit 0b7851a

Please sign in to comment.