Skip to content

Adding an object to more than one parent Document #416

@bbartley

Description

@bbartley

If you try to share the same object across multiple Documents, you can get into trouble. I stumbled upon this problem because I was trying to re-use an Agent object (representing a lab robot) in multiple Documents. How should pysbol3 handle this scenario?

a = sbol3.Agent('lab_robot')
doc1 = sbol3.Document()
doc2 = sbol3.Document()
doc1.add(a)
doc2.add(a)

The object now appears to be registered in both Documents:

>>> a in doc1.objects
True
>>> a in doc2.objects
True

That seems OK. However, the back-pointer to the parent doc is a problem:

>>> a.document == doc1
False
>>> a.document == doc2
True

How should pysbol3 behave? Should it throw an error/warning? Should it attempt to add a duplicate copy of the object instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions