thegetty / crom

Python library to make creation of CIDOC CRM easier by mapping classes/predicates to python objects
Apache License 2.0
49 stars 16 forks source link

#50 broke serialization #51

Closed kasei closed 5 years ago

kasei commented 5 years ago

50 seems to have broken serialization in cases where there are multiple blank node objects being serialized. The behavior makes me think the serializer stores '' as an "identifier" (scare quotes) that it has already handled, and then when it finds a new blank node, it thinks it's already done, so emits just the bare minimum.

In this example, the content of the second identifier just disappears upon serialization:

>>> i1 = vocab.IsbnIdentifier(ident='', content='0000')
>>> i2 = vocab.IsbnIdentifier(ident='', content='9999')
>>> s = vocab.Note()
>>> s.identified_by = i1
>>> s.identified_by = i2
>>> print(factory.toString(s, False))
{
  "@context": "https://linked.art/ns/v1/linked-art.json",
  "id": "http://lod.example.org/museum/LinguisticObject/1",
  "type": "LinguisticObject",
  "classified_as": [
    {
      "id": "http://vocab.getty.edu/aat/300027200",
      "type": "Type",
      "_label": "Note"
    },
    {
      "id": "http://vocab.getty.edu/aat/300418049",
      "type": "Type",
      "_label": "Brief Text"
    }
  ],
  "identified_by": [
    {
      "type": "Identifier",
      "content": "0000",
      "classified_as": [
        {
          "id": "http://vocab.getty.edu/aat/300417443",
          "type": "Type",
          "_label": "ISBN Identifier"
        }
      ]
    },
    {
      "type": "Identifier"
    }
  ]
}
azaroth42 commented 5 years ago

Fixed by #52.