Reverse-resolve hex instance numbers in traceback?
Some tracebacks just don't give enough info. I have the following traceback (only the last 3 lines displayed): (Info: ({'script': <PythonScript instance at 8a4a090>, 'context': <r instance at 89a5560>, 'container': <Folder instance at 89ca148>, 'traverse_subpath': []}, (), {}, None)) File Script (Python), line 3, in writer_1_row File /usr/local/python/lib/python2.1/string.py, line 80, in strip The error appeared in line 3, in writer_1_row script. But that script is OK. The problem is caused by a specific ZClass instance which lacks the expected attribute. Is it possible to reverse-resolve hex instance numbers in the traceback to find out which instance it is? -- Milos Prudek _________________ Most websites are confused chintzy gaudy conflicting tacky unpleasant... unusable. Learn how usable YOUR website is! http://www.spoxdesign.com
On Tue, 2003-10-07 at 02:30, Milos Prudek wrote:
The error appeared in line 3, in writer_1_row script. But that script is OK. The problem is caused by a specific ZClass instance which lacks the expected attribute.
Is it possible to reverse-resolve hex instance numbers in the traceback to find out which instance it is?
Sure... you *can* get the address of an object by getting the string representation of it using backticks, ex: `my_obj` A better way might be something some Python like this: ----------- for obj in container.objectValues(my_obj_type) if hasattr(obj, attribute_name): print obj['id'] return printed ----------- That would give you a list of *all* the objects that lack the specific attribute, not just the one that you think you're looking for. HTH, Dylan
On Tue, 2003-10-07 at 08:06, Dylan Reinhardt wrote:
A better way might be something some Python like this:
----------- for obj in container.objectValues(my_obj_type) if hasattr(obj, attribute_name): print obj['id'] return printed -----------
And you'll want to put a colon at the end of that first line. :-) Dylan
Sure... you *can* get the address of an object by getting the string representation of it using backticks, ex:
`my_obj`
So, for example, I can do the following? print `<Folder instance at 89ca148>` Is that what you mean? -- Milos Prudek _________________ Most websites are confused chintzy gaudy conflicting tacky unpleasant... unusable. Learn how usable YOUR website is! http://www.spoxdesign.com
On Wed, 2003-10-08 at 04:53, Milos Prudek wrote:
Sure... you *can* get the address of an object by getting the string representation of it using backticks, ex:
`my_obj`
So, for example, I can do the following?
print `<Folder instance at 89ca148>`
Is that what you mean?
No, it wasn't. Backticks cause an object to be represented as a string. Typically this operator produces a string of the form: <CLASS_NAME instance at HEX_ADDR> The backticks themselves go around the object name. To take your example: (note ticks on the name, single quotes on the string) `my_folder_name` might return '<Folder instance at 89ca148>' What I was suggesting is that it is *possible* (though not necessarily useful) to iterate over a collection of objects and test each one's string representation to see if it matches the hex address you already have. When you find a match, you print the object's id. But as I also mentioned, a far smarter thing is to test each object for the specific attributes that you think are missing. That process will ultimately be much more useful. HTH, Dylan
Milos Prudek wrote at 2003-10-8 13:53 +0200:
Sure... you *can* get the address of an object by getting the string representation of it using backticks, ex:
`my_obj`
So, for example, I can do the following?
print `<Folder instance at 89ca148>`
Is that what you mean?
It will give you a "SyntaxError". He meant: If you have an object ("obj"), you can (often) get its address by "`obj`". Python does not allow you to reverse this (at least not unless it is specially compiled). Dieter
participants (3)
-
Dieter Maurer -
Dylan Reinhardt -
Milos Prudek