[Zope] How to convert string to object?

Edward Muller edwardam@interlix.com
07 Mar 2003 00:07:32 -0600


If your asking that question there is a possibility that you don't
understand zope acquisition. Which is all right ... I think we all
didn't get it at one point.

I assume you want to use index_html as a template (or wrapper) for the
content in some deeper folder?

If so all you need to do (sorry this is in zpt ... don't use dtml much
anymore)...

in a zpt in your root folder  ..

<html>
  <body>
    <div>
      or table or what not containing whatever you 
      want to appear before the "content"
    </div>
    <div tal:content="structure here/content"/>
    <div>
      or table or what not containing whatever you 
      want to appear after the "content"
    </div>
  </body>
</html>

Now just create folders ... and stick a file (dtml or zpt or python
script or whatever) called 'content' wherever you want it to appear.

So if I had a folder layout like the following: 

/articles/linux/2003/03/07/01

I would put a zpt (or dtml document/method) called 'content' in the
/articles/linux/2003/03/07/01 folder.

And when I surfed to:

http://server/articles/linux/2003/03/07/01

I would get the content file 'wrapped' with the index_html somewhere up
the folder 'path'.

You can further customize things by using macros and slots and all the
zpt goodies. Plus if you ever need to 'override' your index_html file
deeper in you folder 'tree' just create a new one at the highest level
you want to start using it.

Hope this helps 


On Thu, 2003-03-06 at 08:49, Lubos Culen wrote:
> Hi!
> 
> Maybe this is more Python question, but because I'm using it with Zope, I'm 
> posting it here.
> 
> Let's suppose I have DTML Method called e.g. 'index_html' . It has one 
> input parameter 'obj' which contains name of existing file object inside 
> the directory tree. For example, the index_html file would be called as:
> 
> www.mysite.com/path/index_html?obj=path.to.object.file
> 
> Then in folder www.mysite.com/path/path/to/object/file in this example 
> would be the DTML document I'd like to be displayed. I have to make proper 
> code in the index_html file do do this.
> 
> I tried do following in index_html:
> 
> <dtml-var obj>
> 
> But this echoes only plain text ('path.to.object.file') and not the 
> object's content. I need to find some way how to convert this string to 
> object, so Zope (or Python) can understand it as an object and display its 
> content. Is there some way?
> 
> Thanks a lot for any answer!
-- 
Edward Muller

Interlix - President

Web Hosting - PC Service & Support
Custom Programming - Network Service & Support

Phone: 417-862-0573
 Cell: 417-844-2435
  Fax: 417-862-0572

http://www.interlix.com