[Zope] rendering the contents of ..

J Cameron Cooper zope-l at jcameroncooper.com
Mon Aug 1 14:38:04 EDT 2005


David Bear wrote:
> I am looking at a couple way of producing a qotd solution.
> 
> one way is to put quotes in a folder. Then use objectvalues on the
> folder  and randomly select one of the items. I get get the objectid.
> but I don't know what I use to get the 'content' of the object.. what
> is the method to get the 'rendered' and unrendered content of an
> object.
> 
> In this case I'm using objects of type file (setting content type to
> text/plain) (ofcourse the content is plain text)
> 
> I may find the using a zpt, html, or stx object will work better. I'm
> hoping there is a method to get either a rendered view of the file,
> (if zope knows how to render it) or unrendered, and I'll worry about
> rendering it elsewhere.

The contents of a File object can be gotten at simply by calling it. You 
can also get at the underlying data with the 'data' attribute, which is 
useful if the contents are large (since it provides a 'Pdata' object 
rather than a string.) This is just as it says in 
http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixB.stx

Other object types, like those that have to do rendering, you can just 
call for the rendered content. Methods 'document_src' or 'read' will 
usually work for the source.

		--jcc
-- 
"Building Websites with Plone"
http://plonebook.packtpub.com


More information about the Zope mailing list