From b5962a098ae9c5b9c8b0014db84b9ab66120acd9 Mon Sep 17 00:00:00 2001 From: BaiJiangJie Date: Thu, 4 Jul 2019 17:09:36 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E8=A7=A3=E5=86=B3select=5Ffor=5Fupd?= =?UTF-8?q?ate=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/api/session.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/terminal/api/session.py b/apps/terminal/api/session.py index 6dd48f591..2a92c7bc9 100644 --- a/apps/terminal/api/session.py +++ b/apps/terminal/api/session.py @@ -38,12 +38,12 @@ class SessionViewSet(OrgBulkModelViewSet): ('date_start', ('date_from', 'date_to')) ] - def get_object(self): + def filter_queryset(self, queryset): + queryset = super().filter_queryset(queryset) # 解决guacamole更新session时并发导致幽灵会话的问题 - obj = super().get_object() - if self.request.method in ('PATCH', ): - obj = obj.select_for_update() - return obj + if self.request.method in ('PATCH',): + queryset = queryset.select_for_update() + return queryset @property def filter_backends(self):