[Zope] How to disply a property of an object created with a Z
class
Satheesh Babu
vattekkat.babu@verizon.net
26 Jan 2003 21:22:18 -0500
you will need to actually get the object from the string id
<dtml-with "_.getattr(this(), document_id)">
<dtml-var body>
</dtml-with>
Or simply
<dtml-var "(_.getattr(this(), document_id)).body">
I've not tested this. See the cookbook entry at:
http://www.zopelabs.com/cookbook/1001104105
--
Vattekkat S Babu
http://vsbabu.org/
On Sun, 2003-01-26 at 19:21, pieter claassen wrote:
> Oh, I also didn't add the following bit of info. If I hard code the
> display_body method to be:
>
> <dtml-var standard_html_header>
>
> <dtml-with REQUEST>
>
> <dtml-with name="001"> # 001 is the id of the message
>
> <dtml-var body> # body is a text property of the message
>
> </dtml-with>
>
> </dtml-with>
>
> <dtml-var standard_html_footer>
>
> Then it works fine.
>
>
>
> Thanks,
>
> Pieter
>
>
>
>
>
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org] On Behalf Of
> pieter claassen
> Sent: 26 January 2003 23:12
> To: zope@zope.org
> Subject: [Zope] How to disply a property of an object created with a Z
> class
>
>
>
> I used a Z class to write a basic news pinup board for my site.
> Everything is working fine but I reached a point where I am trying to
> publish only the heading and a summary of the message while asking users
> to click on a link to view the body of the message
>
>
>
> I have created a newster class which is my news server instance. The
> newster class contains the messages class which is the blueprint for
> each of the messages that I am going to add. Each message is an object
> in the newster directory.
>
> The message objects each have a number of properties such as expired,
> title, id, summary and body.
>
>
>
> I have two methods:
>
> 1. index_html that prints the title and summary of each message instance
> one after the other on a long page.
>
> 2. display_body that will print the body of the message in a new window.
>
>
>
> The problem:
>
>
>
> I pass the id of the message whose body must be displayed in a url like:
> display_body?document_id=<id>
>
>
>
> Here is what I believe the basic code of the display_body method should
> be:
>
> <dtml-var standard_html_header>
>
> <dtml-with REQUEST>
>
> <dtml-with expr="document_id">
>
> <dtml-var body>
>
> </dtml-with>
>
> </dtml-with>
>
> <dtml-var standard_html_footer>
>
>
>
> I can print the document_id as a dtml-var but somehow I cannot get zope
> to understand it is the name of an object whose body property I want to
> display.
>
>
>
> But, somehow, zope does not push the properties of the document_id
> (which it received through the web) on top of the namespace and
> therefore it believes that there is no such thing as a body property.
>
>
>
> Any help will be greatly appreciated. This is driving me nuts.
>
> Thanks,
>
> Pieter
>