1
0
mirror of https://github.com/gsi-upm/senpy synced 2025-09-18 04:22:21 +00:00

Added Model string representation

This should help with performance issues with models that have large
private variables.
This commit is contained in:
J. Fernando Sánchez
2017-02-02 04:46:35 +01:00
parent ceed9b97d0
commit b072121e20
3 changed files with 17 additions and 2 deletions

View File

@@ -147,6 +147,9 @@ class SenpyMixin(object):
obj = obj.jsonld()
jsonschema.validate(obj, self.schema)
def __str__(self):
return str(self.to_JSON())
class SenpyModel(SenpyMixin, dict):
@@ -198,7 +201,8 @@ class SenpyModel(SenpyMixin, dict):
def _plain_dict(self):
d = {k: v for (k, v) in self.items() if k[0] != "_"}
d["@id"] = d.pop('id')
if 'id' in d:
d["@id"] = d.pop('id')
return d