[Zope3-checkins] SVN: Zope3/branches/jinty-zodbless/src/zope/app/appsetup/ Rather than fail with a cryptic error message, fail with a more explanatory one.

Brian Sutherland jinty at web.de
Tue Apr 10 22:44:16 EDT 2007


Log message for revision 74098:
  Rather than fail with a cryptic error message, fail with a more explanatory one.

Changed:
  U   Zope3/branches/jinty-zodbless/src/zope/app/appsetup/appsetup.py
  U   Zope3/branches/jinty-zodbless/src/zope/app/appsetup/tests/schema.txt

-=-
Modified: Zope3/branches/jinty-zodbless/src/zope/app/appsetup/appsetup.py
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/appsetup/appsetup.py	2007-04-10 19:02:37 UTC (rev 74097)
+++ Zope3/branches/jinty-zodbless/src/zope/app/appsetup/appsetup.py	2007-04-11 02:44:15 UTC (rev 74098)
@@ -214,6 +214,11 @@
 def setup_app_factory(database_factories):
     app_factory = zope.component.queryUtility(zope.app.appsetup.interfaces.IApplicationFactory)
     if app_factory is None:
+        if not database_factories:
+            raise AssertionError("No database factories were passed (no "
+                                 "<zodb> section in zope.conf?), and there "
+                                 "is no IApplicationFactory utility registered. "
+                                 "You need one of either.")
         # We don't have an application factory registered, so we try to make
         # a ZODB one from the options (probably parsing the options should
         # just register the utility in future)

Modified: Zope3/branches/jinty-zodbless/src/zope/app/appsetup/tests/schema.txt
===================================================================
--- Zope3/branches/jinty-zodbless/src/zope/app/appsetup/tests/schema.txt	2007-04-10 19:02:37 UTC (rev 74097)
+++ Zope3/branches/jinty-zodbless/src/zope/app/appsetup/tests/schema.txt	2007-04-11 02:44:15 UTC (rev 74098)
@@ -53,7 +53,15 @@
 
     >>> ztapi.unprovideUtility(IApplicationFactory)
 
+If we have no <zodb> section, and no IApplicationFactory utility
+registered, we should produce an understandable error message:
 
+    >>> from zope.app.appsetup.appsetup import setup_app_factory
+    >>> setup_app_factory(options.databases)
+    Traceback (most recent call last):
+        ...
+    AssertionError: No database ...
+
 Application Factory Setup in zope.conf (ZODB)
 =============================================
 



More information about the Zope3-Checkins mailing list