[Zope] Newbies & variables

Troy Farrell troy@entheossoft.com
Tue, 05 Feb 2002 00:31:36 -0600


Alright.  What does it return?
Based upon this:

 >>>    return special_formats['structured-text'](_[page_body])

It should return the result of calling whatever method is returned by 
getting the 'structured-text' element of the special_formats dictionary 
with page_body as the only argument.  Whew!  Why don't you just do this:

myhome.html:

<dtml-var name="standard_html_header">
<dtml-let page_body="'stuff.stx'">
   <dtml-var name="dtml_wrapper">
</dtml-let>
<dtml-var name="standard_html_footer">

dtml_wrapper:

<dtml-if name="page_body">
   <dtml-if expr="page_body[-4:] == '.stx'">
     <dtml-var name="page_body" fmt="structured-text">
   <dtml-else>
     <dtml-var name="page_body">
   </dtml-if>
<dtml-else>
   <dtml-var name="default_page">
</dtml-if>

Am I making sense, or missing the point?  Alright, I admit it.  I really 
like DTML (though sometimes...)

Troy

Gary Learned wrote:

> Well, I added it as a parameter, and that fixed the immediate problem,
> however it doesn't return myhome.stx as it should....curiouser and
> curiouser.
> 
> 
>>-----Original Message-----
>>From: Troy Farrell [mailto:troy@entheossoft.com] 
>>Sent: Sunday, February 03, 2002 12:11 AM
>>To: Gary Learned
>>Cc: zope@zope.org
>>Subject: Re: [Zope] Newbies & variables
>>
>>
>>Gary,
>>Is page_body listed as a Python Script parameter?  If not, try adding 
>>it.  If so, this could be significantly more complex.
>>Troy
>>
>>-- 
>>Troy Farrell
>>Developer
>>Entheos Software
>>mailto:troy@entheossoft.com
>>http://www.entheossoft.com
>>
>>
>>Gary Learned wrote:
>>
>>
>>>In working thru the examples in the Zope Web Applications 
>>>
>>book, it is 
>>
>>>demonstrating the use of python scripts. I have the following code
>>>elements:
>>>
>>>myhome.html:
>>>
>>><dtml-let page_body="'myhome.stx'">
>>>  <dtml-var standard_dtml_wrapper>
>>></dtml-let>
>>>
>>>standard_dtml_wrapper:
>>>
>>><html>
>>>	<head>
>>>		<title><dtml-var title_or_id></title>
>>>	</head>
>>>	<body>
>>>		<dtml-var banner>
>>>		<dtml-call choose_page_body>
>>>	</body>
>>></html>
>>>
>>>And finally, choose_page_body (type script)
>>>
>>>from Products.PythonScripts.standard import special_formats
>>>
>>>if page_body :
>>>  if page_body[-4] == ".stx" :
>>>    return special_formats['structured-text'](_[page_body])
>>>  else :
>>>    return _[page_body]
>>>else :
>>>  return default_page
>>>
>>>
>>>In thiscase, I also bound namespace=_
>>>
>>>My problem is that when trying to view this, I get an error on 
>>>page_body indicating that the python script knows nothing about it. 
>>>Since this is all originating from within the <dtml-let> block, I 
>>>thought it would carry thru. Since it isn't, how do I fix this?