<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.3314.2100" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>I would not use the name 'getObject' as this is the name of a 
zope routine.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>I like to use dtml-with statements to access subfolders (easy, 
maintainable, and I usually do more than one thing in a given subfolder at a 
given time)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>eg</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&lt;dtml-with Plone&gt;</FONT></DIV>
<DIV><FONT size=2>&nbsp; &lt;dtml-with reports&gt;</FONT></DIV>
<DIV><FONT size=2>&nbsp;&nbsp;&nbsp; &lt;dtml-with Site2&gt;</FONT></DIV>
<DIV><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;dtml-var 
myObject&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>If you do want to use restrictedTraverse you can do it with 
dtml:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&lt;dtml-var 
"restrictedTraverse('Plone/reports/Site2/myObject')"&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>however you must ensure the myObject is something that the 
dtml-var tag can work with (eg. if myObject is a zclass with property fields, 
dtml-var won't be able to display anything for you - you won't get an error, 
just nothing will show - unless you view the html source code that is rendered 
and you will see something like '&lt;zclassname at myObject&gt;')</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>HTH</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>Jonathan</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A href="mailto:rubemontejano@yahoo.com" title=rubemontejano@yahoo.com>Ruben 
  Montejano</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A href="mailto:zope@zope.org" 
  title=zope@zope.org>zope@zope.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> December 10, 2003 5:24 PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [Zope] help with 
  restrictedTraverse</DIV>
  <DIV><BR></DIV>
  <DIV>Hi everybody,</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp; The task I am trying to accomplish is to be able to call an 
  object(it could<BR>be a dtml method, python script, php document, etc), given 
  its path as a string<BR>parameter.</DIV>
  <DIV>&nbsp;&nbsp; Let's say my directory structure looks like this:</DIV>
  <DIV>/-+-Plone-+-homepage 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +-reports-+-Site1 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  +-Site2-+-myObject 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  +-... <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +-... </DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; I need to call myObject, which path is 
  '/Plone/reports/Site2/', from any<BR>other directory within the directory 
  structure, but at this time I'm using<BR>homepage.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; Browsing the mailing list I found that I could use 
  restrictedTraverse, so<BR>I created an External Method getObject under the 
  homepage directory with the<BR>following code:</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>def getObject( self ):</DIV>
  <DIV>&nbsp;&nbsp;&nbsp; return 
  self.restrictedTraverse('/Plone/reports/Site2/myObject')</DIV>
  <DIV><BR>myObject in this case is a php document that contains: </DIV>
  <DIV>&lt;?php</DIV>
  <DIV>include "<A 
  href="http://2ksvr/ploneSupp/lines.php?wk=2002-06-01">http://2ksvr/ploneSupp/lines.php?wk=2002-06-01</A>";</DIV>
  <DIV>?&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Now using the External Method from the homepage's index_html:</DIV>
  <DIV>&lt;dtml-var getObject&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>This is what I get, instead of the chart that this object 
  displays:<BR>&lt;?php include "<A 
  href="http://2ksvr/ploneSupp/lines.php?wk=2002-06-01">http://2ksvr/ploneSupp/lines.php?wk=2002-06-01</A>"; 
  ?&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>I also tried creating a python script with the following code:</DIV>
  <DIV>return 
  container.restrictedTraverse('/Plone/pig_reports/test_farrowing/crChart')</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>but the script returns this:</DIV>
  <DIV>&amp;lt;?php</DIV>
  <DIV>include 
  &amp;quot;http://2ksvr/ploneSupp/lines.php?wk=2002-06-01&amp;quot;;</DIV>
  <DIV>?&amp;gt;</DIV>
  <DIV><BR>What&nbsp;am I&nbsp;doing wrong? Any ideas or help is more than 
  welcome.</DIV>
  <DIV>Thanks,</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ruben 
  Montejano.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; email: <A 
  href="mailto:rubemontejano@yahoo.com">rubemontejano@yahoo.com</A><BR></DIV><BR><BR>----------------------------------------------------<BR>Ruben 
  Montejano.<BR>phone: (309) 837-2318<BR>email: rubemontejano@yahoo.com
  <P>
  <HR SIZE=1>
  Do you Yahoo!?<BR><A 
  href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=21260/*http://photos.yahoo.com">New 
  Yahoo! Photos - easier uploading and sharing</A>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>Zope maillist&nbsp; 
  -&nbsp; 
  Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**&nbsp;&nbsp; 
  No cross posts or HTML encoding!&nbsp; **<BR>(Related lists - 
  <BR>&nbsp;http://mail.zope.org/mailman/listinfo/zope-announce<BR>&nbsp;http://mail.zope.org/mailman/listinfo/zope-dev 
  )<BR></BLOCKQUOTE></BODY></HTML>