[Zope] Product data acquisition by <dtml-var>

Anders Karlsson pugo at cendio.se
Thu Apr 21 10:46:59 EDT 2005


I am working some on a product where I have some problems making a nice 
interface to the calling dtml-code. My product grabs and caches RSS data for 
a feed, and now I would like to make an interface much like the one that is 
provided by the "Z SQL Method". My problem is that I can't find any 
documentation or examples of how to make this work with the acquisition.

I would like to be able to do something like this to show the results of the 
object my_feed:

   <dtml-in my_feed>
      <dtml-var title><br>
      <dtml-var date><br>
      <dtml-var description><br>
      <hr>
   </dtml-in>


I have found out that I in my product class can have a __len__() function that 
returns the result size and a __getitem__() function that returns a numbered 
element. If I return a mapping from that function I can access the resulting 
values as I want, but to make it work I need to add the "mapping" attribute 
to my <dtml-in>-tag. I would like to get the same result without having to 
tell dtml-in that it's a mapping, just like "Z SQL Method" does. 

I have tried to understand the "Z SQL Method" code, and I see that it returns 
objects of a result class from the __getitem__() function. Is there any 
specifications telling which functions such a class needs to implement? I 
have tried doing such a result class, but when I execute the code I get:

   Error Value: unbound Python method must be called with RSSItem 1st argument

Can anyone please point me to some documentation or in any other way enlighten 
me? 

Thanks in advance!
--------------------------------------------------------------------------
Anders Karlsson                        Email:  anders.karlsson at cendio.se
Cendio AB                              WWW:    www.cendio.se
Teknikringen 3,                        Voice:  +46 - (0)13 - 21 46 00
SE-583 30  LINKÖPING, SWEDEN           Fax:    +46 - (0)13 - 21 47 00


More information about the Zope mailing list