Better diagnostics during product load?
Often, when Zope tries to load my product, it logs the simple error message: 2000-02-21T23:51:57 ERROR(200) Zope Couldn't install MyProduct There is no traceback, not in the log and not in the product screen of the Control Panel. I presume the problem is syntax errors in the Python code of the product. How can I get Zope to show me a traceback pointing out the syntax errors? -- Thanks -- Loren
Often, when Zope tries to load my product, it logs the simple error message: 2000-02-21T23:51:57 ERROR(200) Zope Couldn't install MyProduct There is no traceback, not in the log and not in the product screen of the Control Panel. I presume the problem is syntax errors in the Python code of the product.
How can I get Zope to show me a traceback pointing out the syntax errors?
In the __init__.py for your product, use a try: except to print out the traceback. try: <product initialization here> except: import traceback traceback.print_exc() This will print the traceback to stderr. -jfarr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hi! I'm a signature virus. Copy me into your .sig to join the fun! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Often, when Zope tries to load my product, it logs the simple error message: 2000-02-21T23:51:57 ERROR(200) Zope Couldn't install MyProduct There is no traceback, not in the log and not in the product screen of the Control Panel. I presume the problem is syntax errors in the Python code of the product.
How can I get Zope to show me a traceback pointing out the syntax errors?
In the __init__.py for your product, use a try: except to print out the traceback.
try:
<product initialization here>
except: import traceback traceback.print_exc()
This will print the traceback to stderr.
-jfarr
Thanks for your suggestion. I tried that, but it didn't help -- same result. If there's a syntax error in the module, Python won't even execute the "try...except", will it? -- Loren
Loren Stafford wrote:
Often, when Zope tries to load my product, it logs the simple error message: 2000-02-21T23:51:57 ERROR(200) Zope Couldn't install MyProduct There is no traceback, not in the log and not in the product screen of the Control Panel. I presume the problem is syntax errors in the Python code of the product.
How can I get Zope to show me a traceback pointing out the syntax errors?
In the __init__.py for your product, use a try: except to print out the traceback.
try:
<product initialization here>
except: import traceback traceback.print_exc()
This will print the traceback to stderr.
-jfarr
Thanks for your suggestion. I tried that, but it didn't help -- same result. If there's a syntax error in the module, Python won't even execute the "try...except", will it?
Taking a look at gtk's Boring Product documentation. In there is a method for getting the traceback information into Zope, to see when you click on the broken product in the products screen. http://www.Zope.org/Members/gtk/Boring/HowTo-Boring That should help. Bill -- In flying I have learned that carelessness and overconfidence are usually far more dangerous than deliberately accepted risks. -- Wilbur Wright in a letter to his father, September 1900
Loren Stafford wrote:
Often, when Zope tries to load my product, it logs the simple error message: 2000-02-21T23:51:57 ERROR(200) Zope Couldn't install MyProduct There is no traceback, not in the log and not in the product screen
of
the
Control Panel. I presume the problem is syntax errors in the Python code of the product.
How can I get Zope to show me a traceback pointing out the syntax errors?
In the __init__.py for your product, use a try: except to print out the traceback.
try:
<product initialization here>
except: import traceback traceback.print_exc()
This will print the traceback to stderr.
-jfarr
Thanks for your suggestion. I tried that, but it didn't help -- same result. If there's a syntax error in the module, Python won't even execute the "try...except", will it?
Taking a look at gtk's Boring Product documentation. In there is a method for getting the traceback information into Zope, to see when you click on the broken product in the products screen.
http://www.Zope.org/Members/gtk/Boring/HowTo-Boring
That should help.
Bill
I'm already doing that. Strangely enough, the product does not show up as broken on the products screen -- it looks like a normally installed product. But it clearly is not installed: 1. Zope said it didn't install 2. It's private objects weren't created 3. It left no entries in the zLOG other than the standard ones and the one mentioned above (I have logging calls at each step in it's installation, including one as the first statement of initialize(context)). So the problem is how to get some debug info BEFORE Zope tries to execute initialize(). -- Loren
Thanks for your suggestion. I tried that, but it didn't help -- same result.
You have to run zope in debug mode or you won't see anything that gets written to stdout or stderr.
If there's a syntax error in the module, Python won't even execute the "try...except", will it?
You're right. It won't catch SyntaxError exceptions. Those will be caught in the try block containing the import statement. It's also possible to debug your product from the interpreter, which would show you those errors.
From your $ZOPE_HOME/lib/python directory:
import Zope import Products.<product name> <= should get a SyntaxError exception here if you're going to get one. -jfarr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hi! I'm a signature virus. Copy me into your .sig to join the fun! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
participants (3)
-
Bill Anderson -
Jonothan Farr -
Loren Stafford