From e32942a49dc81099e13de339cca584bfdb7a03cd Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer <_@chrisjrn.com> Date: Mon, 4 Jul 2016 22:23:17 +1000 Subject: [PATCH] =?UTF-8?q?Fixes=20django-sitetree=E2=80=99s=20breaking=20?= =?UTF-8?q?of=20500=20reporting.=20(#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pinaxcon/monkey_patch.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pinaxcon/monkey_patch.py b/pinaxcon/monkey_patch.py index a6b6d9cb..a9d99258 100644 --- a/pinaxcon/monkey_patch.py +++ b/pinaxcon/monkey_patch.py @@ -56,3 +56,22 @@ def patch_accounts_to_send_bcc(): email.send() hooks.send_mail = send_mail + + +def fix_sitetree_check_access_500s(): + ''' django-sitetree has a bug: https://github.com/idlesign/django-sitetree/pull/167/files + -- it swallows the cause of all 500 errors. This swallows KeyErrors from + the failing function. ''' + + from sitetree.sitetreeapp import SiteTree + + old_check_access = SiteTree.check_access + + @wraps(SiteTree.check_access) + def check_access(self, *a, **k): + try: + return old_check_access(self, *a, **k) + except KeyError: + return False + + SiteTree.check_access = check_access