Product data acquisition by <dtml-var>
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@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
Anders Karlsson wrote:
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".
Like ZSQL method in what respect exactly?
My problem is that I can't find any documentation or examples of how to make this work with the acquisition.
What "this" are you referring to?
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.
Then looks at returning Result objects, or whatever theyr'e called, like ZSQL methods do...
objects of a result class from the __getitem__() function. Is there any specifications telling which functions such a class needs to implement?
Nope, I'd suggest you just re-use that class, since it likely does exactly what you want ;-)
Error Value: unbound Python method must be called with RSSItem 1st argument
Okay, so lets see a full traceback and the code the traceback refers to. cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (2)
-
Anders Karlsson -
Chris Withers