Python 2.7 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Python.
Stay organized with collections
Save and categorize content based on your preferences.
google.appengine.api.yaml_object module
Summary
Builder for mapping YAML documents to object instances.
ObjectBuilder is responsible for mapping a YAML document to classes defined
using the validation mechanism (see google.appengine.api.validation.py).
Contents
- google.appengine.api.yaml_object.BuildObjects(default_class, stream, loader=google.appengine._internal.ruamel.yaml.loader.SafeLoader)source
Build objects from stream.
Handles the basic case of loading all the objects from a stream.
Parameters
-
default_class – Class that is instantiated upon the detection of a new
document. An instance of this class will act as the document itself.
-
stream – String document or open file object to process as per the
yaml.parse method. Any object that implements a ‘read()’ method which
returns a string document will work with the YAML parser.
-
loader_class – Used for dependency injection.
ReturnsList of default_class instances parsed from the stream.
- google.appengine.api.yaml_object.BuildSingleObject(default_class, stream, loader=google.appengine._internal.ruamel.yaml.loader.SafeLoader)source
Build object from stream.
Handles the basic case of loading a single object from a stream.
Parameters
-
default_class – Class that is instantiated upon the detection of a new
document. An instance of this class will act as the document itself.
-
stream – String document or open file object to process as per the
yaml.parse method. Any object that implements a ‘read()’ method which
returns a string document will work with the YAML parser.
-
loader_class – Used for dependency injection.
- class google.appengine.api.yaml_object.ObjectBuilder(default_class)source
-
Bases: google.appengine.api.yaml_builder.Builder
Builder used for constructing validated objects.
Given a class that implements validation.ValidatedBase, it will parse a YAML
document and attempt to build an instance of the class.
ObjectBuilder will only map YAML fields that are accepted by the
ValidatedBase’s GetValidator function.
Lists are mapped to validated. Repeated attributes and maps are mapped to
validated.Type properties.
For a YAML map to be compatible with a class, the class must have a
constructor that can be called with no parameters. If the provided type
does not have such a constructor a parse time error will occur.
- AppendTo(subject, value)source
Append a value to a sequence.
Parameters
- BuildDocument()source
Instantiate new root validated object.
ReturnsNew instance of validated object.
- BuildMapping(top_value)source
New instance of object mapper for opening map scope.
Parameterstop_value – Parent of nested object.
ReturnsNew instance of object mapper.
- BuildSequence(top_value)source
New instance of object sequence.
Parameterstop_value – Object that contains the new sequence.
ReturnsA new _ObjectSequencer instance.
- EndMapping(top_value, mapping)source
When leaving scope, makes sure new object is initialized.
This method is mainly for picking up on any missing required attributes.
Parameters
- MapTo(subject, key, value)source
Map key-value pair to an objects attribute.
ParametersRaises
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003egoogle.appengine.api.yaml_object\u003c/code\u003e module provides tools for mapping YAML documents to object instances, primarily using the \u003ccode\u003eObjectBuilder\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBuildObjects\u003c/code\u003e function handles loading multiple objects from a YAML stream, returning a list of instances of the specified \u003ccode\u003edefault_class\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBuildSingleObject\u003c/code\u003e loads a single object from a YAML stream, also using a provided \u003ccode\u003edefault_class\u003c/code\u003e for instantiation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eObjectBuilder\u003c/code\u003e parses YAML documents and builds instances of classes that implement \u003ccode\u003evalidation.ValidatedBase\u003c/code\u003e, ensuring only validated attributes are mapped.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eObjectBuilder\u003c/code\u003e includes methods such as \u003ccode\u003eAppendTo\u003c/code\u003e, \u003ccode\u003eBuildDocument\u003c/code\u003e, \u003ccode\u003eBuildMapping\u003c/code\u003e, \u003ccode\u003eBuildSequence\u003c/code\u003e, \u003ccode\u003eEndMapping\u003c/code\u003e, and \u003ccode\u003eMapTo\u003c/code\u003e for handling different aspects of YAML document parsing and object construction.\u003c/p\u003e\n"]]],[],null,["# google.appengine.api.yaml_object module\n=======================================\n\nSummary\n-------\n\nBuilder for mapping YAML documents to object instances.\n\nObjectBuilder is responsible for mapping a YAML document to classes defined\nusing the validation mechanism (see google.appengine.api.validation.py).\n\nContents\n--------\n\ngoogle.appengine.api.yaml_object.BuildObjects(default_class, stream, loader=google.appengine._internal.ruamel.yaml.loader.SafeLoader)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#BuildObjects)\n\n: Build objects from stream.\n\n Handles the basic case of loading all the objects from a stream.\n Parameters\n\n - default_class -- Class that is instantiated upon the detection of a new\n document. An instance of this class will act as the document itself.\n\n - stream -- String document or open file object to process as per the\n yaml.parse method. Any object that implements a 'read()' method which\n returns a string document will work with the YAML parser.\n\n - loader_class -- Used for dependency injection.\n\n Returns\n\nList of default_class instances parsed from the stream. \n\ngoogle.appengine.api.yaml_object.BuildSingleObject(default_class, stream, loader=google.appengine._internal.ruamel.yaml.loader.SafeLoader)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#BuildSingleObject)\n\n: Build object from stream.\n\n Handles the basic case of loading a single object from a stream.\n Parameters\n\n - default_class -- Class that is instantiated upon the detection of a new\n document. An instance of this class will act as the document itself.\n\n - stream -- String document or open file object to process as per the\n yaml.parse method. Any object that implements a 'read()' method which\n returns a string document will work with the YAML parser.\n\n - loader_class -- Used for dependency injection.\n\n*class* google.appengine.api.yaml_object.ObjectBuilder(default_class)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder)\n\n: Bases: [google.appengine.api.yaml_builder.Builder](/appengine/docs/legacy/standard/python/refdocs/google.appengine.api.yaml_builder#google.appengine.api.yaml_builder.Builder)\n\n Builder used for constructing validated objects.\n\n Given a class that implements validation.ValidatedBase, it will parse a YAML\n document and attempt to build an instance of the class.\n ObjectBuilder will only map YAML fields that are accepted by the\n ValidatedBase's GetValidator function.\n Lists are mapped to validated. Repeated attributes and maps are mapped to\n validated.Type properties.\n\n For a YAML map to be compatible with a class, the class must have a\n constructor that can be called with no parameters. If the provided type\n does not have such a constructor a parse time error will occur. \n\n AppendTo(subject, value)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder.AppendTo)\n\n : Append a value to a sequence.\n\n Parameters\n\n - subject -- _ObjectSequence that is receiving new value.\n\n - value -- Value that is being appended to sequence.\n\n BuildDocument()[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder.BuildDocument)\n\n : Instantiate new root validated object.\n\n Returns\n\n New instance of validated object. \n\n BuildMapping(top_value)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder.BuildMapping)\n\n : New instance of object mapper for opening map scope.\n\n Parameters\n\n top_value -- Parent of nested object.\n Returns\n\n New instance of object mapper. \n\n BuildSequence(top_value)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder.BuildSequence)\n\n : New instance of object sequence.\n\n Parameters\n\n top_value -- Object that contains the new sequence.\n Returns\n\n A new _ObjectSequencer instance. \n\n EndMapping(top_value, mapping)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder.EndMapping)\n\n : When leaving scope, makes sure new object is initialized.\n\n This method is mainly for picking up on any missing required attributes.\n Parameters\n\n - top_value -- Parent of closing mapping object.\n\n - mapping -- _ObjectMapper instance that is leaving scope.\n\n MapTo(subject, key, value)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/yaml_object#ObjectBuilder.MapTo)\n\n : Map key-value pair to an objects attribute.\n\n Parameters\n\n - subject -- _ObjectMapper of object that will receive new attribute.\n\n - key -- Key of attribute.\n\n - value -- Value of new attribute.\n\n Raises\n\n \u003c!-- --\u003e\n\n - UnexpectedAttribute when the key is not a validated attribute of\n\n - the subject value class."]]