예제 #1
0
    def _save(self, obj, zipfile_=None, refs=None):
        '''
        Saves the object passed in to a zip file. Note that ths name of this
        function is '_save' to allow the attribute 'save' to be used to specify
        if this SchemaNode represents an attribute that should be saved.

        :param obj: Gnome object to be saved
        :param zipfile_: an open zipfile.Zipfile object, in append mode
        :param name: unless specified, uses name of obj
        :param refs: references dict

        :returns Processed json representation of the object.
        When this returns, zipfile_ should be a complete zip savefile of obj,
        and refs will be a dictionary of all GNOME objects keyed by id.
        '''
        if obj is None:
            raise ValueError(self.__class__.__name__ + ': Cannot save a None')
        if obj._schema is not self.__class__:
            raise TypeError('A {0} cannot save a {1}'.format(self.__class__.__name__, obj.__class__.__name__))

        if zipfile is None:
            raise ValueError('Must pass an open zipfile.Zipfile in append mode to zipfile_')
        if refs is None:
            refs = Refs()

        obj_json = self.typ.save(self, obj, zipfile_, refs)
        return obj_json
예제 #2
0
 def deserialize(self, cstruct=None, refs=None):
     if refs is None:
         refs = Refs()
     substitute_schema = self.validate_input_schema(cstruct)
     return substitute_schema.typ.deserialize(substitute_schema,
                                              cstruct,
                                              refs=refs)
예제 #3
0
 def load(self, obj_json, saveloc=None, refs=None):
     if refs is None:
         refs = Refs()
     substitute_schema = self.validate_input_schema(obj_json)
     return substitute_schema.typ.load(substitute_schema,
                                       obj_json,
                                       saveloc=saveloc,
                                       refs=refs)
예제 #4
0
 def _save(self, obj, zipfile_=None, refs=None):
     if refs is None:
         refs = Refs()
     substitute_schema = self.validate_input_schema(obj)
     return substitute_schema.typ.save(substitute_schema,
                                       obj,
                                       zipfile_=zipfile_,
                                       refs=refs)
예제 #5
0
 def deserialize(self, cstruct=None, refs=None):
     if refs is None:
         refs = Refs()
     appstruct = self.typ.deserialize(self, cstruct, refs=refs)
     return appstruct