You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of add_related (used to relate two different objects together) is currently broken. If you create three ObjectProperties (A, B and C), and run the following:
A.add_related(B, ...)
C.add_related(A, ...)
then the relationship between A and B will be broken. This is due to the fact that relationships are between Objects, but the add_related function operates on the contained ObjectProperties. add_related creates a newRelatedObject (see here) as the parent of the ObjectProperties that is being added. Thus, the relationship between A and B is severed as a result of the second call.
A workaround is to switch the order of these calls. This is not a 100% solution for more complicated sets of relationships, but should hopefully help until we can fix this.
fromcybox.objects.artifact_objectimportArtifactfromcybox.objects.email_message_objectimportEmailMessage, Attachmentsfromcybox.objects.file_objectimportFilefilename="example.txt"data="blah blah blah contents of file"f=File()
f.file_name=filenamea=Artifact(data, Artifact.TYPE_FILE)
f.add_related(a, "Child_Of") # This is the A.add_related(B, ...)m=EmailMessage()
m.from_="bob@example.com"m.subject="this is an email"m.attachments=Attachments()
m.add_related(f, "Contains", inline=True) # This is C.add_related(A, ...)# Move it to here: # f.add_related(a, "Child_Of")m.attachments.append(f.parent.id_)
The current implementation of
add_related
(used to relate two different objects together) is currently broken. If you create threeObjectProperties
(A, B and C), and run the following:then the relationship between A and B will be broken. This is due to the fact that relationships are between
Object
s, but theadd_related
function operates on the containedObjectProperties
.add_related
creates a newRelatedObject
(see here) as the parent of theObjectProperties
that is being added. Thus, the relationship between A and B is severed as a result of the second call.A workaround is to switch the order of these calls. This is not a 100% solution for more complicated sets of relationships, but should hopefully help until we can fix this.
Thanks to @brlogan for identifying this bug.
The text was updated successfully, but these errors were encountered: