Thanks Chris! On Saturday 07 December 2002 10:39 pm, Chris McDonough wrote:
It's likely an instance of a "record" object (as defined in lib/Components/ExtensionClass/src/Record.c). I believe the idea for it not having a __dict__ (snicker) was that there can be many, many of these generated for a single SQL query and thus it saved memory at some point in time. I'm not sure how true that is now. It may still be eminently so. They don't have a __dict__ but they are enumerable. Something like this might work (or something along these lines, I have not tested it):
Okay -- that makes the code a little easier to understand.
class my_wrapper: def __init__(self, sqlres): d = {} for k in sqlres.__record_schema__.keys(): d[k] = getattr(sqlres, k) self.__dict__.update(d) my_form = DTMLFile('www/my_form', globals())
def some_method(self, foo): return self.sql_stuff + foo
wrapped_results = [my_wrapper(r) for r in sql_search()]
This works, though I actually coded it like: for k in sqlres.__record_schema__.keys(): self.setattr(k, getattr(sqlres, k)) which is a little more streamlined in code but I have no idea how efficient it is.
In any case, I'm not sure what you mean about type() not working against them [...] If you mean that this is from "trusted" code like a Product, and its repr just doesn't render in your browser, it's because you're viewing the rendering of the error as an HTML page, the repr is between pointy brackets, and your browser just won't show it to you because it thinks it's part of the HTML. View the source of the page instead, or use Zope 2.6 and learn to use the error_log feature.
Duh. Yeah, that was the problem -- thank you for pointing this out! Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com