App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Static Public Attributes | List of all members
google.appengine.api.validation.Validated Class Reference
Inheritance diagram for google.appengine.api.validation.Validated:
google.appengine.api.validation.ValidatedBase google.appengine.api.backendinfo.BackendEntry google.appengine.api.backendinfo.BackendInfoExternal google.appengine.api.client_deployinfo.ClientDeployInfoExternal google.appengine.api.client_deployinfo.Request google.appengine.api.conf.YAMLConfiguration google.appengine.api.croninfo.CronEntry google.appengine.api.croninfo.CronInfoExternal google.appengine.api.dispatchinfo.DispatchEntry google.appengine.api.dispatchinfo.DispatchInfoExternal google.appengine.api.dosinfo.BlacklistEntry google.appengine.api.dosinfo.DosInfoExternal google.appengine.api.pagespeedinfo.PagespeedEntry google.appengine.api.queueinfo.Acl google.appengine.api.queueinfo.QueueEntry google.appengine.api.queueinfo.QueueInfoExternal google.appengine.api.queueinfo.RetryParameters

Public Member Functions

def __init__
 
def GetValidator
 
def Set
 
def Get
 
def CheckInitialized
 
def __setattr__
 
def __str__
 
def __repr__
 
def __eq__
 
def __ne__
 
def __hash__
 
def ToDict
 
- Public Member Functions inherited from google.appengine.api.validation.ValidatedBase
def GetValidator
 
def SetMultiple
 
def Set
 
def CheckInitialized
 
def ToDict
 
def ToYAML
 

Static Public Attributes

 ATTRIBUTES = None
 

Detailed Description

Base class for classes that require validation.

A class which intends to use validated fields should sub-class itself from
this class.  Each class should define an 'ATTRIBUTES' class variable which
should be a map from attribute name to its validator.  For example:

  class Story(Validated):
    ATTRIBUTES = {'title': Type(str),
                  'authors': Repeated(Type(str)),
                  'isbn': Optional(Type(str)),
                  'pages': Type(int),
                  }

Attributes that are not listed under ATTRIBUTES work like normal and are
not validated upon assignment.

Constructor & Destructor Documentation

def google.appengine.api.validation.Validated.__init__ (   self,
  attributes 
)
Constructor for Validated classes.

This constructor can optionally assign values to the class via its
keyword arguments.

Raises:
  AttributeDefinitionError: when class instance is missing ATTRIBUTE
definition or when ATTRIBUTE is of the wrong type.

Member Function Documentation

def google.appengine.api.validation.Validated.__eq__ (   self,
  other 
)
Equality operator.

Comparison is done by comparing all attribute values to those in the other
instance.  Objects which are not of the same type are not equal.

Args:
  other: Other object to compare against.

Returns:
  True if validated objects are equal, else False.
def google.appengine.api.validation.Validated.__hash__ (   self)
Hash function for using Validated objects in sets and maps.

Hash is done by hashing all keys and values and xor'ing them together.

Returns:
  Hash of validated object.
def google.appengine.api.validation.Validated.__ne__ (   self,
  other 
)
Inequality operator.
def google.appengine.api.validation.Validated.__repr__ (   self)
Formatted view of validated object and nested values.
def google.appengine.api.validation.Validated.__setattr__ (   self,
  key,
  value 
)
Set attribute.

Setting a value on an object of this type will only work for attributes
defined in ATTRIBUTES.  To make other assignments possible it is necessary
to override this method in subclasses.

It is important that assignment is restricted in this way because
this validation is used as validation for parsing.  Absent this restriction
it would be possible for method names to be overwritten.

Args:
  key: Name of attribute to set.
  value: Attributes new value.

Raises:
  ValidationError: when trying to assign to an attribute
that does not exist.
def google.appengine.api.validation.Validated.__str__ (   self)
Formatted view of validated object and nested values.
def google.appengine.api.validation.Validated.CheckInitialized (   self)
Checks that all required fields are initialized.

Since an instance of Validated starts off in an uninitialized state, it
is sometimes necessary to check that it has been fully initialized.
The main problem this solves is how to validate that an instance has
all of its required fields set.  By default, Validator classes do not
allow None, but all attributes are initialized to None when instantiated.

Raises:
  Exception relevant to the kind of validation.  The type of the exception
  is determined by the validator.  Typically this will be ValueError or
  TypeError.
def google.appengine.api.validation.Validated.Get (   self,
  key 
)
Get a single value on Validated instance.

This method can only be used to retrieve validated attributes.

Args:
  key: The name of the attributes

Raises:
  ValidationError when no validated attribute exists on class.
def google.appengine.api.validation.Validated.GetValidator (   self,
  key 
)
Safely get the underlying attribute definition as a Validator.

Args:
  key: Name of attribute to get.

Returns:
  Validator associated with key or attribute value wrapped in a
  validator.
def google.appengine.api.validation.Validated.Set (   self,
  key,
  value 
)
Set a single value on Validated instance.

This method can only be used to assign validated attributes.

Args:
  key: The name of the attributes
  value: The value to set

Raises:
  ValidationError when no validated attribute exists on class.
def google.appengine.api.validation.Validated.ToDict (   self)
Convert Validated object to a dictionary.

Recursively traverses all of its elements and converts everything to
simplified collections.

Returns:
  A dict of all attributes defined in this classes ATTRIBUTES mapped
  to its value.  This structure is recursive in that Validated objects
  that are referenced by this object and in lists are also converted to
  dicts.

The documentation for this class was generated from the following file: