references relationlist problems

5 views
Skip to first unread message

Jordan Baker

unread,
Nov 25, 2009, 1:18:24 PM11/25/09
to dexterity-...@googlegroups.com
Using this example we've been having problems with all content items
getting the same list of values:

relatedItems = RelationList(
title=u"Related Items",
default=[],
value_type=RelationChoice(title=_(u"Related"),
source=ObjPathSourceBinder()),
required=False,
)

I suspect that possibly each content item has the same instance of the
literal list [] defined in our schema.

Short of creating a separate content class so its possible to
initialize the attribute to a unique list, is there a better way to do
this?

-jordan.

Alec Mitchell

unread,
Nov 25, 2009, 1:38:45 PM11/25/09
to dexterity-...@googlegroups.com
There's no obvious way that I can think of. What happens if you don't
set a default (e.g. leave None as the default)? A validation error or
schema error on startup of some sort? If that's the case I'd argue
this needs to be fixed in zope.schema for schema fields that represent
mutable types. We could always fix it in the __init__ of RelationList
in z3c.relationfield, but that's probably the wrong layer to be
addressing this.

Alec

Jordan Baker

unread,
Nov 25, 2009, 2:04:34 PM11/25/09
to dexterity-...@googlegroups.com
I should note that TTW this isn't a problem. I suspect the various
widgets setup fresh lists to assign them.

So far it only showed up in tests where we used invokeFactory to
create the content and then used .append to add some relations.

-jordan.
Reply all
Reply to author
Forward
0 new messages