def _construct_from_json ( self , rec ) : self . delete ( ) for required_key in [ 'dagobah_id' , 'created_jobs' ] : setattr ( self , required_key , rec [ required_key ] ) for job_json in rec . get ( 'jobs' , [ ] ) : self . _add_job_from_spec ( job_json ) self . commit ( cascade = True )
python mongodb object from json
Construct this Dagobah instance from a JSON document .
def _construct_from_json(self, rec):
        """ Construct this Dagobah instance from a JSON document. """

        self.delete()

        for required_key in ['dagobah_id', 'created_jobs']:
            setattr(self, required_key, rec[required_key])

        for job_json in rec.get('jobs', []):
            self._add_job_from_spec(job_json)

        self.commit(cascade=True)