[Zope] Problems with list of object references

Sven Rudolph rudolph@medical-tribune.de
Tue, 13 Aug 2002 14:33:40 +0200


Hello Dieter,

thank you for your reply!


>  > ...When I open "show_list" in my browser I can see the list like this:
>  > [<MyOtherProduct instance at ecdcfa8>, <MyOtherProduct instance at ecdd050>, etc. ]
> You should be very careful with this:
> 
>   Most Zope objects you handle are acquisition wrappers.
What does that mean?


> When you want to make them persistent, you need to strip down the
> wrapper before storing and wrap again on access, something like:
> 
>     self.LIST= [o.aq_base for o in self.restrictedTraverse(...)...]
> 
>   def getLIST(self):
>     return [o.__of__(self) for o in self.LIST]
Hmm..I can't follow you :-(


>  > ...
>  > This seems to work very well. When I open "use_list" in my browser I see a list of ids.
>  > But when I reload "use_list" 3 or 4 times I suddenly get an attribute error for "get", just as if the sequence-item wasn't an object anymore.
> I do not understand it.
> 
>    Instead, you should have gotten an "Unpicklable Error".
>  > The same thing happens when I refresh my product or restart the server.
> Obviously, your objects are not pickled correctly.
As far as I can see it, LIST is stored correctly, but the values in LIST are not valid for more then (let's say) 5 minutes.
 
>    I wonder why they did at all.

Maybe you have a different suggestion for me?
Let me repeat my problem:
I have several folders wich contain instances of several (news) products. There are about 12.000 product instances of 6 (or more) products in 6 (or more) folders. I must put them in one single list, sort this list by "validfrom" (an instance of DateTime inside each product instance) and then return the first 100 entrys in this list. This resulting list must contain references and it must be cacheable.
Or in shorter words: I need a list of references of the newest news on our site.


Greetings

Sven


-- 
Sven Rudolph, Programmierer
GermanMedicalServices.de GmbH
Unter den Eichen 5, 65195 Wiesbaden
Tel.: 06 11 / 97 46 25 2