From patchwork Fri May 27 04:21:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 822802 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4R4Lj0x028310 for ; Fri, 27 May 2011 04:21:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751163Ab1E0EVo (ORCPT ); Fri, 27 May 2011 00:21:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40487 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777Ab1E0EVn (ORCPT ); Fri, 27 May 2011 00:21:43 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4R4LgdP020226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 May 2011 00:21:42 -0400 Received: from justice.redhat.com (vpn-10-216.rdu.redhat.com [10.11.10.216]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4R4LaMM004814; Fri, 27 May 2011 00:21:41 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 2/6] afe/readonly connection: Catch AttributeError exceptions Date: Fri, 27 May 2011 01:21:30 -0300 Message-Id: <1306470094-16960-3-git-send-email-lmr@redhat.com> In-Reply-To: <1306470094-16960-1-git-send-email-lmr@redhat.com> References: <1306470094-16960-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 27 May 2011 04:21:50 +0000 (UTC) On Django 1.3, the DB connection object does not have some of the attributes we are trying to compare on the __neq__ method, resulting on an AttributeError. Let's catch that error so the application works under 1.3. Signed-off-by: Lucas Meneghel Rodrigues --- frontend/afe/readonly_connection.py | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/frontend/afe/readonly_connection.py b/frontend/afe/readonly_connection.py index 7d59aae..68af56c 100644 --- a/frontend/afe/readonly_connection.py +++ b/frontend/afe/readonly_connection.py @@ -89,7 +89,15 @@ class ReadOnlyConnection(object): def close(self): if self._connection is not None: - assert django_connection != self._connection + # Here we are checking if connection can be compared with + # the django DB class, but the connection class under django + # 1.3 doesn't have a settings_dict attribute, generating an + # AttributeError. So if that error is raised, supress it and + # only let the AssertionError pass. + try: + assert django_connection != self._connection + except AttributeError: + pass self._connection.close() self._connection = None