class FayGravityViscousSchema(WeathererSchema): thickness_limit = SchemaNode( Float(), missing=drop, save=True, update=True ) water = WaterSchema( save=True, update=True )
class LangmuirSchema(WeathererSchema): wind = GeneralGnomeObjectSchema( acceptable_schemas=[WindSchema, VectorVariableSchema], save=True, update=True, save_reference=True) water = WaterSchema(save=True, update=True, save_reference=True)
def deserialize(cls, json_): schema = cls._schema(name=cls.__name__) if 'water' in json_: schema.add(WaterSchema(name="water")) _to_dict = schema.deserialize(json_) return _to_dict
def serialize(self, json_="webapi"): toserial = self.to_serialize(json_) schema = self.__class__._schema() if json_ == 'webapi': if self.water is not None: schema.add(WaterSchema(name="water")) serial = schema.serialize(toserial) return serial
def deserialize(cls, json_): """ append correct schema for wind object """ schema = cls._schema() if 'wind' in json_: schema.add(WindSchema(name='wind')) if 'water' in json_: schema.add(WaterSchema(name='water')) return schema.deserialize(json_)
def serialize(self, json_='webapi'): """ Since 'wind'/'water' property is saved as references in save file need to add appropriate node to WindMover schema for 'webapi' """ toserial = self.to_serialize(json_) schema = self.__class__._schema() if json_ == 'webapi': if self.wind: schema.add(WindSchema(name='wind')) if self.water: schema.add(WaterSchema(name='water')) return schema.serialize(toserial)
def serialize(self, json_='webapi'): """ Since 'wind' property is saved as a reference when used in save file and 'save' option, need to add appropriate node to WindMover schema """ toserial = self.to_serialize(json_) schema = self.__class__._schema(name=self.__class__.__name__) if json_ == 'webapi': # add wind schema schema.add(WindSchema(name='wind')) if self.water is not None: schema.add(WaterSchema(name='water')) serial = schema.serialize(toserial) return serial