Google App Engine Python Sdk

ADVERTISEMENT

Google App Engine
Property
is the superclass for data model definitions.
Query
uses objects and methods to prepare queries.
Python SDK 1.2.2
REVISION 1.1 05.21.09
CONSTRUCTOR
CONSTRUCTOR
class Property(verbose_name=None, name=None,
Datastore
class Query(model_class)
google.appengine.ext.db
indexed=True, default=None, choices=None
A scalable storage and query engine.
INSTANCE METHODS
required=False, validator=None)
filter(property_operator, value)
self
CLASS ATTRIBUTES
PACKAGE FUNCTIONS
order(property)
self
data_type
get(key)
Model instance
ancestor(model_instance|key)
self
You can also pass multiple keys and it will return multiple Model instances.
INSTANCE METHODS
get()
model instance or None
default_value()
value
put(model_instance)
Key object
fetch(limit, offset=0)
list of model instances
You can also pass multiple model instances and it will return multiple keys.
validate(value)
value or exception
count(limit=None)
integer
empty(value)
bool
delete(model_instance|key)
Key
represents a unique key for a datastore entity.
TYPE AND PROPERTY CLASSES
run_in_transaction(function, *args, **kwargs)
run_in_transaction_custom_retries(retries, function,
CONSTRUCTOR
Property Class
Value Type
Sort Order
*args, **kwargs)
class Key(encoded=None)
StringProperty
str
Unicode (str is treated as ASCII)
unicode
Model
is the superclass for data model definitions.
CLASS METHODS
ByteStringProperty
db.ByteString
byte order
Key.from_path(*args, **kwds)
CONSTRUCTOR
BooleanProperty
bool
False < True
This example creates a key for an Address entity with the numeric ID 9876 whose par-
class Model(parent=None, key_name=None, **kwds)
ent is a User entity with the named key ‘Boris’:
IntegerProperty
int
Numeric
CLASS METHODS
long
k = Key.from_path(‘User’, ‘Boris’, ‘Address’, 9876)
get(key)
Key object
FloatProperty
float
Numeric
INSTANCE METHODS
get_by_id(id, parent=None)
Model instance
DateTimeProperty
datetime.datetime
Chronological
app()
Application name (string)
You can also pass multiple ids and it will return multiple Model instances.
DateProperty
kind()
Kind (string)
TimeProperty
get_by_key_name(key_name, parent=None)
see above
id()
Numeric ID (int)
ListProperty
list
If ascending, by least element; if
You can also pass multiple ids and it will return multiple Model instances.
StringListProperty
descending, by greatest element
name()
Entity name (string)
get_or_insert(key_name, **kwds)
see above
ReferenceProperty
db.Key
By path elements (kind, ID or name)
id_or_name()
Numeric ID(int) or name (string)
SelfReferenceProperty
all()
Query object
has_id_or_name()
bool
UserProperty
user.User
By email address
gql(query_string, *args, **kwds)
GQLQuery object
parent()
Key
BlobProperty
db.Blob
(not orderable)
Examples:
GQL
is a SQL-like language for retrieving entities.
TextProperty
db. T ext
(not orderable)
s = Story.gql(“WHERE title = :1”, “The Little Prince”)
SYNTAX
s = Story.gql(“WHERE title = :title”, title=”The Little Prince”)
CategoryProperty
db.Category
Unicode
WHERE <condition> [AND <condition> ...]
kind()
Kind
LinkProperty
db.Link
Unicode
ORDER BY <property> [ASC | DESC] [,<property> [ASC | DESC]…]
properties()
dict
LIMIT [<offset>,]<count>
EmailProperty
db.Email
Unicode
INSTANCE METHODS
OFFSET <offset>
GeoPtProperty
db.GeoPt
By latitude, then longitude
key()
Key
<condition> := <property> {< | <= | > | >= | = | != } <value>
put()
Key
<condition> := <property> IN <list>
IMProperty
db.IM
Unicode
<condition> := ANCESTOR IS <entity or key>
delete()
PhoneNumberProperty
db.PhoneNumber
Unicode
<list> := (<value>, …)
is_saved()
bool
PostalAddressProperty
db.PostalAddress
Unicode
Note that
and
are substitutions for positional and keyword argu-
:NUMBER
:NAME
parent()
Model
ments, referrring to
(starting at 1) and
respectively. See
*args
**kwds
RatingProperty
db.Rating
Unicode
parent_key()
Key
for example usage. Key-only queries are supported using either
Model.gql()
.
SELECT __key__
to_xml()
XML

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go
Page of 2