Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Serialization/deserialization of smartsheet model objects #160

@dynox

Description

@dynox

Hi,

What is the usecase ?

  1. Download sheet from smartsheet services using smartsheet-python-sdk client

  2. Serialize object to store it in NoSQL database

  3. Fetch object from database and deserialize it to smartsheet.models.Sheet object

Sample code presenting scenario above:

client = smartsheet.Smartsheet('some_token')
sheet = client.Sheets.get_sheet(123123123)

id = database.insert(sheet.to_dict())
raw_object = database.get(id)

deserialized = client.models.Sheet(raw_object)

What is the problem ?

When deserializing object I get following errors:

  1. date parsing errors:

dateutil.parser._parser.ParserError: Unknown string format: 2020-12-18T10:43:24+00:00Z

Sample code to reproduce problem:

from smartsheet import smartsheet

sheet = smartsheet.models.Sheet({'createdAt': '2000-01-02T03:04:05Z'})
serialized = sheet.to_dict()
smartsheet.models.Sheet(serialized)
  1. other errors

This one is related to Sight object internals. Fetching Sight from server works and object can be created, but after serializing this object (if has some internal problem with sheet reference) - it is not possible to reconstruct it during deserialization

model_1 | File "/usr/local/lib/python3.9/site-packages/smartsheet/models/widget.py", line 84, in contents
model_1 | widget_type = value['type']
model_1 | KeyError: 'type'

Serialized widget object content looks like that:

widgets": [{"error": {"code": 1170, "errorCode": 1170, "message": "The sheet referenced by this widget is unavailable or deleted.", "refId": "b6f3clf1h5n8"},...

Expected result

  1. It should be possible to deserialize smartsheet object from its serialized representation

Am I doing something wrong during serialization/deserialization process?

Thanks,
P.

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