Hi all. It looks like I've hit something which is already known (I've found this reference: http://mail.zope.org/pipermail/zope-collector-monitor/2004-October/004316.ht... ) I've a custom standard_error_html page, made with a Zope Page Template. I'm trying to provide a custom __str__ for a custom exception. This works, most of the time, but in some cases I encounter the following error: TypeError: unbound method __str__() must be called with InvalidFolderId instance as first argument (got nothing instead) InvalidFolderId is the custom exception, of course. This is the code of the exception: class InvalidFolderId(Exception): def __init__(self, folder_id): self.folder_id = folder_id def __str__(self): return "folder id %s could not be found in the database" % self.folder_id folder_id is a number. What could be done to avoid this problem? Thank you in advance for the help. Regards Marco
Marco Bizzarri wrote at 2005-7-19 10:31 +0200:
... I've a custom standard_error_html page, made with a Zope Page Template. I'm trying to provide a custom __str__ for a custom exception. This works, most of the time, but in some cases I encounter the following error:
TypeError: unbound method __str__() must be called with InvalidFolderId instance as first argument (got nothing instead)
As usual, you must get and look at the corresponding traceback. It will tell you where "__str__" is inappropriately used. If the error is generated from your "standard_error_message" (what you might call "standard_error_html" -- Note: it is very important to use the precise names!), then it may not be that easy to get the traceback. In our Zope copy, I have introduced a log call in case "standard_error_message" raises an exception to get at this traceback. The place for this measure is in "OFS.SimpleItem.SimpleItem.raise_standard_error" (or similarly named). -- Dieter
participants (2)
-
Dieter Maurer -
Marco Bizzarri