[Zope] Newbie Question: dir(...)

Tiller, Michael (M.M.) mtiller@ford.com
Fri, 6 Jun 2003 09:41:47 -0400


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C32C31.60451162
Content-Type: text/plain;
	charset="iso-8859-1"

In using Zope (and Plone), I'm always amazed at how extensible the system
is.  I've managed to create several special macros in Plone for creating
some nice helper "boxes" for my slots.  BUT, the problem I always have is
that while the system has lots of functionality, I never know what it is.
Lots of Zope sites have comments about "see the Zope Book", but I find "the
Zope Book" rather frustrating because it seems to cover things only at a
conceptual level and doesn't really provide a good reference book.
 
For example, I was working (by example) on developing a nice little box for
one of my slots that would list the "Files" in the current folder (and only
in the current folder).  Since I was converting this from the "newsBox"
macro, I saw roughly what needed to be done.  I managed to find some
document somewhere that covered the details of searchResults, but what I was
struggling with mostly was something very simple:
 
At the point where the macro is run, there is a variable called "here"
available.  Ignoring the background questions for the moment (who sets
this?, is it set for all documents?, what is the "type" of this variable?),
I had a very simple question.  I know I have this variable, what can I do
with it?  I just wanted to find out the parent object and then, ultimately,
the path of the parent object so that I could use that as an argument to
searchResults.
 
It took me forever to finally come up with:
path='/'.join(here.aq_parent.getPhysicalPath()) because I didn't know about
aq_parent, I didn't know about getPhysicalPath(), etc.
 
It would really have helped me to know what the attributes and methods are
for each of these objects.  I tried using "dir", e.g.:
 
<div tal:replace="python:dir(here)"></div>
 
But this generated an error because it said "dir" was undefined.  Is there a
simple way, when working within the Zope framework, to quickly determine
what methods are available on an object?
 
Looking at the wealth of Zope code out there, I feel I must be missing
something that other people are using in developing the code.  Either there
are some development tools are some great sources of documentation that I'm
unaware of?!?
 
--
Mike
 

------_=_NextPart_001_01C32C31.60451162
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 5.50.4912.300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>In using Zope (and Plone), 
I'm always amazed at how extensible the system is.&nbsp; I've managed to create 
several special macros in Plone for creating some nice helper&nbsp;"boxes" for 
my slots.&nbsp; BUT, the problem I always have is that while the system has lots 
of functionality, I never know what it is.&nbsp; Lots of Zope sites have 
comments about "see the Zope Book", but I find "the Zope Book" rather 
frustrating because it seems to cover things only at a conceptual level and 
doesn't really provide a good reference book.</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>For example, I was working 
(by example) on developing a nice little box for one of my slots that would list 
the "Files" in the current folder (and only in the current folder).&nbsp; Since 
I was converting this from the "newsBox" macro, I saw roughly what needed to be 
done.&nbsp; I managed to find some document somewhere that covered the details 
of searchResults, but what I was struggling with mostly was something very 
simple:</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>At the point where the 
macro is run, there is a variable called "here" available.&nbsp; Ignoring the 
background questions for the moment (who sets this?, is it set for all 
documents?, what is the "type" of this variable?), I had a very simple 
question.&nbsp; I know I have this variable, what can I do with it?&nbsp; I just 
wanted to find out the parent object and then, ultimately, the path of the 
parent object so that I could use that as an argument to 
searchResults.</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>It took me forever to 
finally come up with: path='/'.join(here.aq_parent.getPhysicalPath()) because I 
didn't know about aq_parent, I didn't know about getPhysicalPath(), 
etc.</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>It would really have helped 
me to know what the attributes and methods are for each of these objects.&nbsp; 
I tried using "dir", e.g.:</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>&lt;div 
tal:replace="python:dir(here)"&gt;&lt;/div&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>But this generated an error 
because it said "dir" was undefined.&nbsp; Is there a simple way, when working 
within the Zope framework, to quickly determine what methods are available on an 
object?</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>Looking at the wealth of 
Zope code out there, I feel I must be missing something that other people are 
using in developing the code.&nbsp; Either there are some&nbsp;development tools 
are some great sources of documentation that I'm unaware 
of?!?</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>--</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT face=Arial>Mike</FONT></SPAN></DIV>
<DIV><SPAN class=790375612-06062003><FONT 
face=Arial></FONT></SPAN>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C32C31.60451162--