introspection and DatabaseResults objects
Hi, I've created a Python (unsafe) method called "get_related_sql()" which returns a list of <Shared.DC.ZRDB.RDB.DatabaseResults instance at 23023f0> objects. In order to try and work out how to get the data out of these objects, I created another Python (unsafe) method called "inspect()" and tried this... <dtml-in get_related_sql()> <dtml-var "inspect(obj=_['sequence-item'] ) "> </dtml-in> inspect() contains the code... from types import * if type(obj) == InstanceType: return "instance", obj.__members__, obj.__methods__ if type(obj) == StringType: return "string" + ' ' + obj But neither the __members__ or __methods__ bits work. Any ideas how I can discover attributes and methods of arbitrary zope objects thanks -- tom smith | tom@othermedia.com http://www.othermedia.com/blog 3rd Floor, The Pavilion, Newhams Row, London, SE1 3UZ 0207 089 5959
Tom Smith writes:
... accessing the names and values of ZSQL method result records ...
<dtml-let result=_SQLMethod_ column_names="result.names()"> <dtml-in result> <dtml-let row=sequence-item> <dtml-in column_names> <dtml-let column_name=sequence-item> <dtml-var column_name>: <dtml-var "_.getattr(row,column_name)"> </dtml-let> </dtml-in> </dtml-let> </dtml-in> </dtml-let> In short: the results "names" method to get the column names (of the result set) a "Computed Attribute Access" (_.getattr) to get the column values of a row. Dieter
participants (2)
-
Dieter Maurer -
Tom Smith