From 734befa6cf111c7176aac97d07b94e4a71a998c1 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Mon, 28 May 2012 10:24:34 +0200 Subject: [PATCH] No more exception catching! see #249 --- admin/__init__.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/admin/__init__.py b/admin/__init__.py index 02b163356..ca9eeb504 100644 --- a/admin/__init__.py +++ b/admin/__init__.py @@ -33,10 +33,9 @@ parameters.register_admin("ITEMS_PER_PAGE", type="int", deflt=30, def enabled_applications(): """Return the list of currently enabled extensions - Quick fix for #184: - - Just catch the DatabaseError exception raised when runnning the - first ``syncdb`` command. + We check if the table exists before trying to fetch activated + extensions because the admin module is always imported by Django, + even before the database exists (example: the first ``syncdb``). :return: a list """ @@ -44,11 +43,8 @@ def enabled_applications(): result = [("admin", "admin"), ("userprefs", "userprefs")] if db_table_exists("admin_extension"): - try: - exts = Extension.objects.filter(enabled=True) - result += [(ext.name, ext.name) for ext in exts] - except DatabaseError: - pass + exts = Extension.objects.filter(enabled=True) + result += [(ext.name, ext.name) for ext in exts] return sorted(result, key=lambda e: e[0]) parameters.register_admin("DEFAULT_TOP_REDIRECTION", type="list", deflt="admin",