frustrated by inability to introspect...
I have the following little snippet of pt code: <form action="edit_list"> <select name="listname"> <option tal:repeat="item container/enumerate_lists" tal:content="item">list</option> </select> <input type="submit" value="Edit"> </form> container/enumerate_lists is a ZSQL method that performs a simple query: select listname from mailinglists All I want to do is display the listnames as form option values. I can't figure out what attributes "item" has. The dir() builtin isn't exposed as far as I can tell. I've been wandering all over the Zope Book for about 20 minutes and have so far been unable to find the attributes associated with the "item" object. Where should I be looking? Is there a rough Zope equivalent to >>> dir("abc") ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__repr__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] or >>> print "".capitalize.__doc__ S.capitalize() -> string Return a copy of the string S with only its first character capitalized. ? Thx, -- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
In this case, "item" is user-defined. For each iteration, it's whatever kind of object is in the sequence that is returned from "container/enumerate_lists". By your description, in this case, all elements in this sequence will be ZSQL "brain" objects. These objects are really just simple wrappers that you can call getitem on with column names and get back something reasonable. Their class is defined in lib/python/Shared/DC/ZRDB/Results.py and is named "Results". You may be interested in this, however if you want to just bust down into a Python prompt and call methods and whatnot: http://www.zope.org/Members/michel/HowTos/TheDebuggerIsYourFriend http://www.zope.org/Members/mcdonc/HowTos/UsingTheZopeDebugger HTH, - C On Fri, 2002-10-25 at 23:54, Skip Montanaro wrote:
I have the following little snippet of pt code:
<form action="edit_list"> <select name="listname"> <option tal:repeat="item container/enumerate_lists" tal:content="item">list</option> </select> <input type="submit" value="Edit"> </form>
container/enumerate_lists is a ZSQL method that performs a simple query:
select listname from mailinglists
All I want to do is display the listnames as form option values. I can't figure out what attributes "item" has. The dir() builtin isn't exposed as far as I can tell. I've been wandering all over the Zope Book for about 20 minutes and have so far been unable to find the attributes associated with the "item" object. Where should I be looking? Is there a rough Zope equivalent to
>>> dir("abc") ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__repr__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
or
>>> print "".capitalize.__doc__ S.capitalize() -> string
Return a copy of the string S with only its first character capitalized.
?
Thx,
-- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Chris> By your description, in this case, all elements in this sequence Chris> will be ZSQL "brain" objects.... Chris> You may be interested in this, however if you want to just bust Chris> down into a Python prompt and call methods and whatnot: ... Yes, thanks. I'm more interested in the "teach me to fish" than "hand me a fish" approach. Skip
On Sat, Oct 26, 2002 at 01:02:06AM -0400, Chris McDonough wrote:
You may be interested in this, however if you want to just bust down into a Python prompt and call methods and whatnot:
http://www.zope.org/Members/michel/HowTos/TheDebuggerIsYourFriend http://www.zope.org/Members/mcdonc/HowTos/UsingTheZopeDebugger
Good, let's try an interactive introspection session: python $ import Zope $ app = Zope.app() $ dir(app.standard_html_header) [] $ dir(app.standard_html_header) ['__name__', '_vars', 'globals', 'raw', 'title'] $ app.standard_html_header.manage_edit <Python Method object at 0x85a8c60> Well, I chose manage_edit because I knew *beforehand* that it exists, but how do I find out *which other methods are available* at this step (for e.g. app.standard_html_header). http://www.zope.org/Documentation/Books/ZDG/current/TestingAndDebugging.stx has the comment: "Of course it won't show you acquired methods and attributes, but that's what aq_parent and such are for. -- chrism" Some more detail at this step would be very much appreciated - simply a "$ dir(app.standard_html_header.aq_parent)" will not show manage_edit either.
On Fri, 2002-10-25 at 23:54, Skip Montanaro wrote:
... and have so far been unable to find the attributes associated with the "item" object. Where should I be looking? Is there a rough Zope equivalent to
>>> dir("abc") ['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
-- Holger
Skip Montanaro writes:
I have the following little snippet of pt code:
<form action="edit_list"> <select name="listname"> <option tal:repeat="item container/enumerate_lists" tal:content="item">list</option> </select> <input type="submit" value="Edit"> </form>
container/enumerate_lists is a ZSQL method that performs a simple query:
select listname from mailinglists
All I want to do is display the listnames as form option values. I can't figure out what attributes "item" has. You "item"s are "Record" objects. Its attributes are the rows of the ZSQL query (in some way). I.e., you can use: 'tal:content="item/listname"'.
Dieter
participants (4)
-
Chris McDonough -
Dieter Maurer -
Holger Blasum -
Skip Montanaro