adding metadata to a substanced ReferenceType

32 views
Skip to first unread message

Jo G

unread,
Jul 7, 2015, 9:03:15 AM7/7/15
to substanc...@googlegroups.com
Pretty much as described in this article for Plone, I would like to create a ReferenceType but that has metadata attached to it rather than either of the objects.



I can see the extra methods or properties on to my ReferenceType but I am having difficulty working out how to access them. Any advice? 

Jo G

unread,
Jul 9, 2015, 10:34:58 AM7/9/15
to substanc...@googlegroups.com

ok, so having looked at

 

http://docs.plone.org/old-reference-manuals/archgenxml/basic-features/relationships-between-classes-and-objects.html

 

https://github.com/plone/Products.Relations/blob/master/Products/Relations/components/contentreference.py

 

I think the steps would be:

 

The reference is stored as a property of the source object. In my case I have

     author_ids = multireference_sourceid_property(PoemToPerson)

 

I need to:

Change the multireference to a reference

Create ContentReferenceClass which inherits from ReferenceClass but allows the addition of ContentItem, a content object to the reference.

The ContentItem object has the same name as the Reference.

Rather than call author_ids = multireference_sourceid_property(PoemToPerson)

 

I will need to do something along the lines of


poem. author = (ref.getContentObject((PoemToPerson), ref.reference_sourceid_property(PoemToPerson))


I then update the content object and the reference as I need to.

 

Am I on the right track or going completely in the wrong direction?

Anything to look out for?

Carlos de la Guardia

unread,
Jul 9, 2015, 2:56:16 PM7/9/15
to substanc...@googlegroups.com
Note that ReferenceType is used as a class, not an instance, so subclassing one like you propose won't get you the desired behavior. Substance D relation classes are not like Plone's, they are mostly markers for the type of relation.

The reference and multireference objects are facilities to connect (reference) objects, so one approach might be to create an intermediate content type (not a ReferenceType, but a real content type) and add reference properties to the original referenced types.

One other thing you can do that is more similar to the Plone approach, might be to add a btree or persistentdict (depending on how many referenced objects there might be) to your ReferenceType, and store the content objects there with the target or source id (or both) as a key, then make the getContentObject use that to get the metadata.

I'm not totally sure what you are trying, but this may at least help you experiment with other approaches.

Carlos de la Guardia


From: Jo G <joannegil...@gmail.com>
To: substanc...@googlegroups.com
Sent: Thursday, July 9, 2015 9:34 AM
Subject: Re: adding metadata to a substanced ReferenceType

--
You received this message because you are subscribed to the Google Groups "substanced-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to substanced-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Jo G

unread,
Jul 14, 2015, 6:02:12 AM7/14/15
to substanc...@googlegroups.com, cgua...@yahoo.com
Hi, thanks for the reply. I see what you are saying.

I need relationships between content types with persistent data attached to that relationship.

One example is:
Poem content object
Person content object.
One or many people are related to one or many poems. They have a role with regard to the poem - that role information is assigned to the relationship rather than the person or the poem. There could also be a confidence level regarding the relationship, again attached to the relationship.

A second example includes a third object - book content object.
Each poem is found in one or many books. The poem has people associated with it in the book (eg a note in the book saying the poem was written by Shakespeare). These relationships will also have confidence levels. This type of three way relationship is in addition to the poem to person relationship.

All the data which is associated with the relationship must be persisted. There could be thousands of these relationships. Hanging all of them from the ReferenceType class seems to me to not make as much sense as creating an intermediate content object. I will need to think through how and where we assign the references (at source and target (poem, person) to the linking content object.

Anything I should look out for?
Reply all
Reply to author
Forward
0 new messages