google.appengine.api.yaml_object.ObjectBuilder

Builder used for constructing validated objects.

Inherits From: Builder, expected_type

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.

The constructor initializes the validated object builder.

default_class Class that is instantiated upon the detection of a new document. An instance of this class will act as the document itself.

Methods

AppendTo

View source

Append a value to a sequence.

Args
subject _ObjectSequence that is receiving new value.
value Value that is being appended to sequence.

BuildDocument

View source

Instantiate new root validated object.

Returns
New instance of validated object.

BuildMapping

View source

New instance of object mapper for opening map scope.

Args
top_value Parent of nested object.

Returns
New instance of object mapper.

BuildSequence

View source

New instance of object sequence.

Args
top_value Object that contains the new sequence.

Returns
A new _ObjectSequencer instance.

EndMapping

View source

When leaving scope, ensures the new object is initialized.

This method is mainly for picking up on any missing required attributes.

Args
top_value Parent of closing mapping object.
mapping _ObjectMapper instance that is leaving scope.

EndSequence

View source

Previously constructed sequence scope is at an end.

Called when the end of a sequence block is encountered. Useful for additional clean up or end of scope validation.

Args
top_value Value which is the parent of the sequence.
sequence Sequence which is at the end of its scope.

InitializeDocument

View source

Initializes document with a value from the top level of a YAML document.

This method is called when the root document element is encountered at the top level of a YAML document. It should get called immediately after BuildDocument.

Receiving the None value indicates the empty document.

Args
document Document as constructed in BuildDocument.
value Scalar value to initialize the document with.

MapTo

View source

Maps key-value pair to an objects attribute.

Args
subject _ObjectMapper of object that will receive new attribute.
key Key of attribute.
value Value of new attribute.

Raises
UnexpectedAttribute when the key is not a validated attribute of the subject value class.