<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thierry Florac wrote:
<blockquote
cite="mid:20100129171632.114a6e5a@m03089.branche00.arbre.foret.onf.fr"
type="cite">
<pre wrap="">Le vendredi 29 janvier 2010,
Vladislav Vorobiev <a class="moz-txt-link-rfc2396E" href="mailto:vavvav@mykniga.de"><vavvav@mykniga.de></a> a écrit :
======================================================================
...
</pre>
<blockquote type="cite">
<pre wrap="">Thierry thank you for answer but it doesn't help.
I implement all what you sad. I tried with normal “list” and than
swiched to “PersistentList”
code looks like that:
from persistent.list import PersistentList
import transaction
<snip>
myList=PersistentList([self.context.pfad, 'object])
myList[0] = PersistentList([self.context.pfad, 'object])[0] #hope I
anderstud you right
ob.refList= myList
ob._p_changed = True
ob.refList._p_changed = True
self.context._setObject(id, ob)
After add I call again:
ob._p_changed = True
ob.refList._p_changed = True
transaction.commit()
I see the commitet trunsactions in ZMI
The same problem. After restart ist the Attribut not in context.
For example return's
Before restart: ***1
ob.refList[0].objectValues()[0].absolute_url()
/pfad/object/FirstObjectOfReferencedObject
After restart only the id of the object:
ob.refList[0].objectValues()[0].absolute_url()
FirstObjectOfReferencedObject
Here is a place for an other question:
Normaly self.absolute_url() returns url with hostname,
(<a class="moz-txt-link-freetext" href="http://localhost/bla/bla">http://localhost/bla/bla</a>)
but already befor restart I get without <a class="moz-txt-link-freetext" href="http://localhost/">http://localhost/</a>... see ***1
It seem's that I forgot something. I would be glad to if somebody
explain me this problem.
</pre>
</blockquote>
<pre wrap=""><!---->======================================================================
In fact I'm not really sure to understand your data structure and it's
goals...
Could you explain me what you want to do ??
Thierry
</pre>
</blockquote>
I want to set some references from object to another object through. I
try to explain this with example classes.<br>
<br>
Example with two classes:<br>
<br>
#Create classes<br>
>>>class School:<br>
>>> pass<br>
<br>
>>>class People:<br>
>>> pass<br>
<br>
#Create objects<br>
>>>p=People()<br>
<br>
>>>s0=School()<br>
>>>s0.name="Konrad School"<br>
<br>
>>>s1=School<br>
>>>s1.name="Leopold School"<br>
<br>
Now I set the referece<br>
<br>
>>>p.school1=s0<br>
>>>p.school2=s1<br>
<br>
Now I can access through the attribut to s0 and s1 objects:<br>
<br>
p.school1.name<br>
“Konrad School“<br>
<br>
This construction works persistent without problems.<br>
<br>
The idea is to put the references in a list.<br>
<br>
>>>p.schools=[s0,s1]<br>
<br>
to access them <br>
<br>
>>>p.schools[0].name<br>
“Konrad School“<br>
<br>
>>>s1.name="Leo School"<br>
>>>p.schools[1].name<br>
“Leo School“<br>
<br>
>>>type(p.schools[1])<br>
<type 'classobj'><br>
<br>
It works in zope without restart. If the server was restartet I get
some unwanted results. See my previews posts.<br>
The same effects I get with PersistentLists...<br>
<br>
I hope it is more understandable.<br>
<br>
Thanks<br>
Vlad<br>
</body>
</html>