Issue 95 in dexterity: RelationValue from_object changed and invalid after Zope restart

8 views
Skip to first unread message

codesite...@google.com

unread,
Nov 26, 2009, 10:46:56 AM11/26/09
to dexterity-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 95 by r...@jackiewicz.ca: RelationValue from_object changed and
invalid after Zope restart
http://code.google.com/p/dexterity/issues/detail?id=95

First of all this issue I believe deals with the z3c.relationfield
package but I am filing it under dexterity since it involves dexterity
content types and some dexterity developers work on z3c.relationfield.

The symptom that was noticed that when you restart zope, the
relationValue object that is stored in the a RelationList field is
changed and now stores an incorrect from_object. For example, if the
object exists at /x/y/object, after restart the from_object is said to
exist at /object, which further cause ovious errors when trying to
access the object since /object has never existed.

This affects both the Alpha 1 & 2 releases of dexterity

Steps to reproduce the problem:

1) Create two dexterity object, one with a similar (schema)field as below:

categories = RelationList(
title=_(u'Categories'),
value_type=RelationChoice(title=_(u'Related Category'),

source=ObjPathSourceBinder(object_provides=ICategory.__identifier__)),
required=False)

2) TTW add a relation to the object with the above field.
3) Restart zope.
4) Inspect the from_object of the RelationValue that was stored.

Expected Output:

Valid RelationValue object that is the same before zope was shutdown.
Ex: RelationValue.from_object (before shutdown)
<item at /x/y/object>
RelattionValue.from_object (after restart)
<item at /x/y/object>

Actual Output:

RelationValue.from_object (after restart)
<item at /object>

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Nov 26, 2009, 3:23:34 PM11/26/09
to dexterity-...@googlegroups.com

Comment #1 on issue 95 by r...@jackiewicz.ca: RelationValue from_object
changed and invalid after Zope restart
http://code.google.com/p/dexterity/issues/detail?id=95

One symptom is that <RelationValue>.from_object.absolute_url() will always
return the
wrong result in addition to from_path. It seems that the attributes on the
object
are still valid such as title. from_id is also broken.

codesite...@google.com

unread,
Nov 27, 2009, 2:25:57 PM11/27/09
to dexterity-...@googlegroups.com

Comment #2 on issue 95 by r...@jackiewicz.ca: RelationValue from_object
changed and invalid after Zope restart
http://code.google.com/p/dexterity/issues/detail?id=95

It is possible that the from_object loses its aquisition wrapper after zope
restarts.
Note that the to_* variables are unaffected.

codesite...@google.com

unread,
Nov 29, 2009, 7:47:28 AM11/29/09
to dexterity-...@googlegroups.com

Comment #3 on issue 95 by optilude: RelationValue from_object changed and
Alec, do you have an opinion on this?

AFAIR, the aq wrapping happens on intid lookup with five.intid, but it
could be dependent on the local site
manager and so it could fail in some cases, e.g. if you haven't traversed
over the site yet. It should work
"eventually", though.

Alternatively, it could be a problem with the IObjectPath (?) adapter?

codesite...@google.com

unread,
Nov 29, 2009, 1:31:40 PM11/29/09
to dexterity-...@googlegroups.com

Comment #4 on issue 95 by hexsprite: RelationValue from_object changed and
found a workaround which is not to rely on from_object and instead retrieve
the object from IntIds using the
from_id (which is correct),. the resulting object is properly acquisition
wrapped

codesite...@google.com

unread,
Nov 30, 2009, 5:51:41 PM11/30/09
to dexterity-...@googlegroups.com

Comment #5 on issue 95 by r...@jackiewicz.ca: RelationValue from_object
changed and invalid after Zope restart
http://code.google.com/p/dexterity/issues/detail?id=95

The workaround is fine if you will just be using from_object however it
would be good
to fix the acquisition of the RelationValue object itself since it too
loses its
aquisition wrapper.

codesite...@google.com

unread,
Nov 30, 2009, 7:50:42 PM11/30/09
to dexterity-...@googlegroups.com

Comment #6 on issue 95 by alecpm: RelationValue from_object changed and
Unfortunately, there's no simple fix for this. Generally speaking, one
already has access to the wrapped
from_object since that's the object on which the RelationValue is stored.
However, if you obtained the
RelationValue by querying the relation catalog directly, then you'll end up
with an unwrapped RelationValue
with an unwrapped from_object. The issue is that you can't store
acquisition wrappers in the ZODB, and the
from_object is stored directly on the RelationValue in the ZODB.
Additionally, the RelationValue itself does
not support acquisition. We'd need to essentially fork z3c.relationfield
in order to directly add acquisition
support at this level, and I wouldn't recommend that.

The RelationValue could store the from_intid directly and dynamically look
up the from_object, as it does with
the to_object/to_intid, but that would require migrating all existing
RelationValue instances. Again, that fix
would be needed at the z3c.relationfield level. So for now we're stuck
with an unwrapped from_object.
Perhaps the simplest solution would be to provide a simple API for
retrieving back references that mitigates
this problem.

codesite...@google.com

unread,
Nov 30, 2009, 7:58:45 PM11/30/09
to dexterity-...@googlegroups.com

Comment #7 on issue 95 by optilude: RelationValue from_object changed and
... and maybe update the documentation to note this?

Would anyone volunteer to draft a paragraph or two explaining this and
suggest where it could fit into the
Dexterity developer manual?

Martin
Reply all
Reply to author
Forward
0 new messages