def __init__(self, kind, title, kind_properties, contact_properties=[]): """ Ctor. title is the name of this particular entity, e.g. Bob Jones or Mom's Birthday Party. kind_properties is a list of property names that should be included in this entity's XML encoding as first-class XML elements, instead of <property> elements. 'title' and 'content' are added to kind_properties automatically, and may not appear in contact_properties. contact_properties is a list of property names that are Keys that point to Contact entities, and should be included in this entity's XML encoding as <gd:who> elements. If a property name is included in both kind_properties and contact_properties, it is treated as a Contact property. Args: kind: string title: string kind_properties: list of strings contact_properties: list of string """ datastore.Entity.__init__(self, kind) if not isinstance(title, types.StringTypes): raise datastore_errors.BadValueError( 'Expected a string for title; received %s (a %s).' % (title, datastore_types.typename(title))) self['title'] = title self['content'] = '' self._contact_properties = set(contact_properties) assert not self._contact_properties.intersection(self.keys()) self._kind_properties = set(kind_properties) - self._contact_properties self._kind_properties.add('title') self._kind_properties.add('content')