<!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> </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> </DIV>
<DIV><FONT size=2>eg</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2><dtml-with Plone></FONT></DIV>
<DIV><FONT size=2> <dtml-with reports></FONT></DIV>
<DIV><FONT size=2> <dtml-with Site2></FONT></DIV>
<DIV><FONT size=2> <dtml-var
myObject></FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT size=2>If you do want to use restrictedTraverse you can do it with
dtml:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2><dtml-var
"restrictedTraverse('Plone/reports/Site2/myObject')"></FONT></DIV>
<DIV> </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 '<zclassname at myObject>')</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT size=2>HTH</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>Jonathan</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </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> </DIV>
<DIV> 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> Let's say my directory structure looks like this:</DIV>
<DIV>/-+-Plone-+-homepage
<BR> +-reports-+-Site1
<BR>
+-Site2-+-myObject
<BR>
+-... <BR> +-... </DIV>
<DIV> </DIV>
<DIV> 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> </DIV>
<DIV> 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> </DIV>
<DIV>def getObject( self ):</DIV>
<DIV> return
self.restrictedTraverse('/Plone/reports/Site2/myObject')</DIV>
<DIV><BR>myObject in this case is a php document that contains: </DIV>
<DIV><?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>?></DIV>
<DIV> </DIV>
<DIV>Now using the External Method from the homepage's index_html:</DIV>
<DIV><dtml-var getObject></DIV>
<DIV> </DIV>
<DIV>This is what I get, instead of the chart that this object
displays:<BR><?php include "<A
href="http://2ksvr/ploneSupp/lines.php?wk=2002-06-01">http://2ksvr/ploneSupp/lines.php?wk=2002-06-01</A>";
?></DIV>
<DIV> </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> </DIV>
<DIV>but the script returns this:</DIV>
<DIV>&lt;?php</DIV>
<DIV>include
&quot;http://2ksvr/ploneSupp/lines.php?wk=2002-06-01&quot;;</DIV>
<DIV>?&gt;</DIV>
<DIV><BR>What am I doing wrong? Any ideas or help is more than
welcome.</DIV>
<DIV>Thanks,</DIV>
<DIV> </DIV>
<DIV> Ruben
Montejano.<BR> 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
-
Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**
No cross posts or HTML encoding! **<BR>(Related lists -
<BR> http://mail.zope.org/mailman/listinfo/zope-announce<BR> http://mail.zope.org/mailman/listinfo/zope-dev
)<BR></BLOCKQUOTE></BODY></HTML>