SlideShare una empresa de Scribd logo
1 de 2
Descargar para leer sin conexión
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                                               google.appengine.ext.db                                                                                                   class Query(model_class)
                                                                                           	           indexed=True, default=None, choices=None
A scalable storage and query engine.
                                                                                           	           required=False, validator=None)                                             INSTANCE METHODS
                                                                                                                                                                                   filter(property_operator, value)                                                 self
PACKAGE FUNCTIONS                                                                          CLASS ATTRIBUTES
                                                                                                                                                                                   order(property)                                                                  self
get(key)                                                            Model instance        data_type
                                                                                                                                                                                   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
put(model_instance)                                                          Key object   default_value()                                                            value
                                                                                                                                                                                   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
delete(model_instance|key)                                                                empty(value)                                                                    bool

run_in_transaction(function, *args, **kwargs)                                              TYPE AND PROPERTY CLASSES                                                               Key represents a unique key for a datastore entity.
run_in_transaction_custom_retries(retries, function,                                       Property Class          Value Type          Sort Order                                  CONSTRUCTOR
				                              *args, **kwargs)
                                                                                           StringProperty          str                 Unicode (str is treated as ASCII)           class Key(encoded=None)
                                                                                                                   unicode
Model is the superclass for data model definitions.                                                                                                                                CLASS METHODS
                                                                                           ByteStringProperty      db.ByteString       byte order
CONSTRUCTOR                                                                                                                                                                        Key.from_path(*args, **kwds)
                                                                                           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)
get_by_key_name(key_name, parent=None)                                        see above   TimeProperty
                                                                                           ListProperty            list                If ascending, by least element; if          id()                                                         Numeric ID (int)
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
Examples:                                                                                  BlobProperty            db.Blob             (not orderable)

s = Story.gql(“WHERE title = :1”, “The Little Prince”)                                     TextProperty            db.Text             (not orderable)
                                                                                                                                                                                   GQL is a SQL-like language for retrieving entities.
s = Story.gql(“WHERE title = :title”, title=”The Little Prince”)                                                                                                                   SYNTAX
                                                                                           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
key()                                                                              Key    GeoPtProperty           db.GeoPt            By latitude, then longitude                   condition := property { | = |  | = | = | != } value

put()                                                                              Key    IMProperty              db.IM               Unicode                                       condition := property IN list

delete()                                                                                                                                                                            condition := ANCESTOR IS entity or key
                                                                                           PhoneNumberProperty     db.PhoneNumber      Unicode
                                                                                                                                                                                     list := (value, …)
is_saved()                                                                        bool
                                                                                           PostalAddressProperty   db.PostalAddress    Unicode                                     Note that :NUMBER and :NAME are substitutions for positional and keyword argu-
parent()                                                                         Model
                                                                                                                                                                                   ments, referrring to *args (starting at 1) and **kwds respectively. See
                                                                                           RatingProperty          db.Rating           Unicode
parent_key()                                                                       Key                                                                                            Model.gql() for example usage. Key-only queries are supported using either
to_xml()                                                                           XML                                                                                            SELECT __key__.
get_current_user()                                                                User   invalid_email_reason(email_address, field)                                     string
Memcache                                         google.appengine.api.memcache                is_current_user_admin()                                                           bool   is_email_valid(email_address)                                                Boolean
A distributed in-memory data cache that can be used in front of or in
                                                                                               EXCEPTIONS                                                                                send_mail(sender, to, subject, body, **kw)
place of persistent storage.
                                                                                               Error, UserNotFound(), RedirectTooLongError()                                             send_mail_to_admins(sender, subject, body, **kw)

FUNCTIONS                                                                                                                                                                                EXCEPTIONS
set(key, value, time=0, min_compress_len=0)                                            bool   URL Fetch                                     google.appengine.api.urlfetch              Error, BadRequestError, InvalidEmailError,
                                                                                               The URLFetch API can retrieve data using HTTP and HTTPS URLs.                             InvalidAttachmentTypeError, MissingRecipientsError,
True means done while False means an error occured.
                                                                                                                                                                                         MisssingSenderError, MissingSubjectError,
Note that a Memcache key is an arbitrary string, not an instance of db.Key.                                                                                                              MissingBodyError
                                                                                               FUNCTIONS
set_multi(mapping, time=0, key_prefix=’’,                                              list                                                                                             MESSAGE FIELDS (**fields)
                                                                                               fetch(url, payload=None, method=GET,    Response object
	         min_compress_len=0)
                                                                                                     headers=(), allow_truncated=False,                                                  sender, to, cc, bcc, reply_to, subject, body, html,
get(key)                                                                              value         follow_redirects=True, deadline=5)                                                  attachments
get_multi(keys, key_prefix=’’)                                                         dict
                                                                                               RESPONSE OBJECTS
delete(key, seconds=0)                                                       error code       content                                                                                   Images                                           google.appengine.api.images

delete_multi(keys, seconds=0, key_prefix=’’)                                           bool   The body content of the response.                                                         Provides image manipulation using the Picassa Web infrastructure.
add(key, value, time=0, min_compress_len=0)                                            bool
                                                                                               content_was_truncated
add_multi(mapping, time=0, key_prefix=’’,                                              list                                                                                             Image represents image data to be transformed.
                                                                                               True if the allow_truncated parameter to fetch() was True and the
	         min_compress_len=0)                                                                  response exceeded the maximum response size. In this case, the content attribute          CONSTRUCTOR
replace(key, value, time=0, min_compress_len=0)                                        bool   contains the truncated response.                                                          class Image(image_data)
replace_multi(mapping, time=0, key_prefix=’’,                                          list   status_code                                                                               PROPERTIES
	             min_compress_len=0)
                                                                                               The HTTP status code.                                                                     width, height
incr(key, delta=1)                                               int, long or None
                                                                                               headers                                                                                   INSTANCE METHODS
decr(key, delta=1)                                               int, long or None
                                                                                               The HTTP response headers, as a mapping of names to values.                               resize(width=0, height=0)
flush_all()                                                                            bool
                                                                                               EXCEPTION CLASSES                                                                         crop(left_x, top_y, right_x, bottom_y)
get_stats()                                                                            dict
                                                                                               Error, InvalidURLError, DownloadError,                                                    The four number arguments are multiplied by the image’s width and height to define
                                                                                               ResponseTooLargeError                                                                     a bounding box that crops the image. The upper left point of the bounding box is at
User                                                  google.appengine.api.users                                                                                                        (left_x*image_width, top_y*image_height) the lower right point is at
An App Engine application can redirect a user to a Google Accounts                                                                                                                       (right_x*image_width, bottom_y*image_height).
page to sign in register, or sign out.                                                         Mail                                          google.appengine.api.urlfetch
                                                                                                                                                                                         rotate(clockwise_degrees)
                                                                                               Provides two ways to send an email message: the mail.send_mail()
                                                                                                                                                                                         horizontal_flip()
                                                                                               function and the EmailMessage class.
User represents a user with a Google account.
                                                                                                                                                                                         vertical_flip()
CONSTRUCTOR
                                                                                               EmailMessage represents an email message.                                                 im_feeling_lucky()
class User(email=None)
                                                                                                                                                                                         composite(inputs, width, height, color=0,
                                                                                               CONSTRUCTOR
INSTANCE METHODS                                                                                                                                                                         	         output_encoding=images.PNG)
                                                                                               class EmailMessage(**fields)
email()                                                                             string                                                                                              histogram(image_data)                                                                list

nickname()                                                                          string
                                                                                               INSTANCE METHODS                                                                          execute_transforms()                                                 Image Object
                                                                                               check_initialized()	
user_id()                                                                           string                                                                                              FUNCTIONS
                                                                                               initialize(**fields)
This can be the user id of an email address or the full email address if it differs from the                                                                                             They are the same as the instance methods, but they can be performed
application’s auth domain (gmail.com or the Google Apps domain for which the applica-          is_initialized()                                                                  bool   directly on image_data. There is no need to queue them using execute_trans-
tion is registered).                                                                                                                                                                     forms(). They include an additional parameter which is the expected
                                                                                               send()
                                                                                                                                                                                         output_encoding image type, which defaults to PNG.
FUNCTIONS                                                                                      FUNCTIONS
create_login_url(dest_url)                                               string (URL)                                                                                                   EXCEPTIONS
                                                                                               check_email_valid(email_address, field)
create_logout_url(dest_url)                                              string (URL)                                                                                                   Error, TransformationError, BadRequestError,
                                                                                               This raises an InvalidEmailError when the email_address is invalid.
                                                                                                                                                                                         NotImageError, BadImageError, LargeImageError

Más contenido relacionado

La actualidad más candente

PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAPYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
 
jQuery Visual Cheat Sheet (by WOORK)_1
jQuery Visual Cheat Sheet (by WOORK)_1jQuery Visual Cheat Sheet (by WOORK)_1
jQuery Visual Cheat Sheet (by WOORK)_1brecke
 
Introduction To Javascript
Introduction To JavascriptIntroduction To Javascript
Introduction To JavascriptRajat Pandit
 
Esoteric LINQ and Structural Madness
Esoteric LINQ and Structural MadnessEsoteric LINQ and Structural Madness
Esoteric LINQ and Structural MadnessChris Eargle
 
Oop03 6
Oop03 6Oop03 6
Oop03 6schwaa
 
Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)SURBHI SAROHA
 
J query visual-cheat-sheet-1.4.2
J query visual-cheat-sheet-1.4.2J query visual-cheat-sheet-1.4.2
J query visual-cheat-sheet-1.4.2Anuradha
 
Javascript foundations: Introducing OO
Javascript foundations: Introducing OOJavascript foundations: Introducing OO
Javascript foundations: Introducing OOJohn Hunter
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objectsmaznabili
 

La actualidad más candente (13)

PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAPYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYA
 
JSTLQuick Reference
JSTLQuick ReferenceJSTLQuick Reference
JSTLQuick Reference
 
JQuery
JQueryJQuery
JQuery
 
jQuery Visual Cheat Sheet (by WOORK)_1
jQuery Visual Cheat Sheet (by WOORK)_1jQuery Visual Cheat Sheet (by WOORK)_1
jQuery Visual Cheat Sheet (by WOORK)_1
 
Introduction To Javascript
Introduction To JavascriptIntroduction To Javascript
Introduction To Javascript
 
Esoteric LINQ and Structural Madness
Esoteric LINQ and Structural MadnessEsoteric LINQ and Structural Madness
Esoteric LINQ and Structural Madness
 
Oop03 6
Oop03 6Oop03 6
Oop03 6
 
Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)
 
J query visual-cheat-sheet-1.4.2
J query visual-cheat-sheet-1.4.2J query visual-cheat-sheet-1.4.2
J query visual-cheat-sheet-1.4.2
 
201005 accelerometer and core Location
201005 accelerometer and core Location201005 accelerometer and core Location
201005 accelerometer and core Location
 
10slide
10slide10slide
10slide
 
Javascript foundations: Introducing OO
Javascript foundations: Introducing OOJavascript foundations: Introducing OO
Javascript foundations: Introducing OO
 
11 Using classes and objects
11 Using classes and objects11 Using classes and objects
11 Using classes and objects
 

Similar a Google app engine cheat sheet

Python mocking intro
Python mocking introPython mocking intro
Python mocking introHans Jones
 
คลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้น
คลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้นคลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้น
คลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้นFinian Nian
 
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونیاسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونیMohammad Reza Kamalifard
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programmingNeelesh Shukla
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxchetanpatilcp783
 
Javascript fundamentals and not
Javascript fundamentals and notJavascript fundamentals and not
Javascript fundamentals and notSalvatore Fazio
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHoward Lewis Ship
 
The Dark Side of Objective-C
The Dark Side of Objective-CThe Dark Side of Objective-C
The Dark Side of Objective-CMartin Kiss
 
Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...
Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...
Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...João Pascoal Faria
 
Introducing Reactive Machine Learning
Introducing Reactive Machine LearningIntroducing Reactive Machine Learning
Introducing Reactive Machine LearningJeff Smith
 
Building DSLs With Eclipse
Building DSLs With EclipseBuilding DSLs With Eclipse
Building DSLs With EclipsePeter Friese
 
Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Celine George
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 

Similar a Google app engine cheat sheet (20)

First fare 2010 java-introduction
First fare 2010 java-introductionFirst fare 2010 java-introduction
First fare 2010 java-introduction
 
Django Pro ORM
Django Pro ORMDjango Pro ORM
Django Pro ORM
 
Python mocking intro
Python mocking introPython mocking intro
Python mocking intro
 
คลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้น
คลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้นคลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้น
คลาสและการเขียนโปรแกรมเชิงวัตถุเบื้องต้น
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونیاسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
 
Object-oriented programming
Object-oriented programmingObject-oriented programming
Object-oriented programming
 
Chap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptxChap-2 Classes & Methods.pptx
Chap-2 Classes & Methods.pptx
 
Javascript fundamentals and not
Javascript fundamentals and notJavascript fundamentals and not
Javascript fundamentals and not
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
 
Scala - core features
Scala - core featuresScala - core features
Scala - core features
 
Core concepts-javascript
Core concepts-javascriptCore concepts-javascript
Core concepts-javascript
 
The Dark Side of Objective-C
The Dark Side of Objective-CThe Dark Side of Objective-C
The Dark Side of Objective-C
 
Module Ninja .JS
Module Ninja .JSModule Ninja .JS
Module Ninja .JS
 
Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...
Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...
Automating Interaction Testing with UML Sequence Diagrams: Where TDD and UML ...
 
Introducing Reactive Machine Learning
Introducing Reactive Machine LearningIntroducing Reactive Machine Learning
Introducing Reactive Machine Learning
 
Django
Django Django
Django
 
Building DSLs With Eclipse
Building DSLs With EclipseBuilding DSLs With Eclipse
Building DSLs With Eclipse
 
Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16Object Relation Mapping in Odoo 16
Object Relation Mapping in Odoo 16
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 

Más de Piyush Mittal

Más de Piyush Mittal (20)

Power mock
Power mockPower mock
Power mock
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorial
 
Reflection
ReflectionReflection
Reflection
 
Gpu archi
Gpu archiGpu archi
Gpu archi
 
Cuda Architecture
Cuda ArchitectureCuda Architecture
Cuda Architecture
 
Intel open mp
Intel open mpIntel open mp
Intel open mp
 
Intro to parallel computing
Intro to parallel computingIntro to parallel computing
Intro to parallel computing
 
Cuda toolkit reference manual
Cuda toolkit reference manualCuda toolkit reference manual
Cuda toolkit reference manual
 
Matrix multiplication using CUDA
Matrix multiplication using CUDAMatrix multiplication using CUDA
Matrix multiplication using CUDA
 
Channel coding
Channel codingChannel coding
Channel coding
 
Basics of Coding Theory
Basics of Coding TheoryBasics of Coding Theory
Basics of Coding Theory
 
Java cheat sheet
Java cheat sheetJava cheat sheet
Java cheat sheet
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Css cheat sheet
Css cheat sheetCss cheat sheet
Css cheat sheet
 
Cpp cheat sheet
Cpp cheat sheetCpp cheat sheet
Cpp cheat sheet
 
Ubuntu cheat sheet
Ubuntu cheat sheetUbuntu cheat sheet
Ubuntu cheat sheet
 
Php cheat sheet
Php cheat sheetPhp cheat sheet
Php cheat sheet
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheet
 
Open ssh cheet sheat
Open ssh cheet sheatOpen ssh cheet sheat
Open ssh cheet sheat
 

Google app engine cheat sheet

  • 1. 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 google.appengine.ext.db class Query(model_class) indexed=True, default=None, choices=None A scalable storage and query engine. required=False, validator=None) INSTANCE METHODS filter(property_operator, value) self PACKAGE FUNCTIONS CLASS ATTRIBUTES order(property) self get(key) Model instance data_type 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 put(model_instance) Key object default_value() value 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 delete(model_instance|key) empty(value) bool run_in_transaction(function, *args, **kwargs) TYPE AND PROPERTY CLASSES Key represents a unique key for a datastore entity. run_in_transaction_custom_retries(retries, function, Property Class Value Type Sort Order CONSTRUCTOR *args, **kwargs) StringProperty str Unicode (str is treated as ASCII) class Key(encoded=None) unicode Model is the superclass for data model definitions. CLASS METHODS ByteStringProperty db.ByteString byte order CONSTRUCTOR Key.from_path(*args, **kwds) 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) get_by_key_name(key_name, parent=None) see above TimeProperty ListProperty list If ascending, by least element; if id() Numeric ID (int) 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 Examples: BlobProperty db.Blob (not orderable) s = Story.gql(“WHERE title = :1”, “The Little Prince”) TextProperty db.Text (not orderable) GQL is a SQL-like language for retrieving entities. s = Story.gql(“WHERE title = :title”, title=”The Little Prince”) SYNTAX 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 key() Key GeoPtProperty db.GeoPt By latitude, then longitude condition := property { | = | | = | = | != } value put() Key IMProperty db.IM Unicode condition := property IN list delete() condition := ANCESTOR IS entity or key PhoneNumberProperty db.PhoneNumber Unicode list := (value, …) is_saved() bool PostalAddressProperty db.PostalAddress Unicode Note that :NUMBER and :NAME are substitutions for positional and keyword argu- parent() Model ments, referrring to *args (starting at 1) and **kwds respectively. See RatingProperty db.Rating Unicode parent_key() Key Model.gql() for example usage. Key-only queries are supported using either to_xml() XML SELECT __key__.
  • 2. get_current_user() User invalid_email_reason(email_address, field) string Memcache google.appengine.api.memcache is_current_user_admin() bool is_email_valid(email_address) Boolean A distributed in-memory data cache that can be used in front of or in EXCEPTIONS send_mail(sender, to, subject, body, **kw) place of persistent storage. Error, UserNotFound(), RedirectTooLongError() send_mail_to_admins(sender, subject, body, **kw) FUNCTIONS EXCEPTIONS set(key, value, time=0, min_compress_len=0) bool URL Fetch google.appengine.api.urlfetch Error, BadRequestError, InvalidEmailError, The URLFetch API can retrieve data using HTTP and HTTPS URLs. InvalidAttachmentTypeError, MissingRecipientsError, True means done while False means an error occured. MisssingSenderError, MissingSubjectError, Note that a Memcache key is an arbitrary string, not an instance of db.Key. MissingBodyError FUNCTIONS set_multi(mapping, time=0, key_prefix=’’, list MESSAGE FIELDS (**fields) fetch(url, payload=None, method=GET, Response object min_compress_len=0) headers=(), allow_truncated=False, sender, to, cc, bcc, reply_to, subject, body, html, get(key) value follow_redirects=True, deadline=5) attachments get_multi(keys, key_prefix=’’) dict RESPONSE OBJECTS delete(key, seconds=0) error code content Images google.appengine.api.images delete_multi(keys, seconds=0, key_prefix=’’) bool The body content of the response. Provides image manipulation using the Picassa Web infrastructure. add(key, value, time=0, min_compress_len=0) bool content_was_truncated add_multi(mapping, time=0, key_prefix=’’, list Image represents image data to be transformed. True if the allow_truncated parameter to fetch() was True and the min_compress_len=0) response exceeded the maximum response size. In this case, the content attribute CONSTRUCTOR replace(key, value, time=0, min_compress_len=0) bool contains the truncated response. class Image(image_data) replace_multi(mapping, time=0, key_prefix=’’, list status_code PROPERTIES min_compress_len=0) The HTTP status code. width, height incr(key, delta=1) int, long or None headers INSTANCE METHODS decr(key, delta=1) int, long or None The HTTP response headers, as a mapping of names to values. resize(width=0, height=0) flush_all() bool EXCEPTION CLASSES crop(left_x, top_y, right_x, bottom_y) get_stats() dict Error, InvalidURLError, DownloadError, The four number arguments are multiplied by the image’s width and height to define ResponseTooLargeError a bounding box that crops the image. The upper left point of the bounding box is at User google.appengine.api.users (left_x*image_width, top_y*image_height) the lower right point is at An App Engine application can redirect a user to a Google Accounts (right_x*image_width, bottom_y*image_height). page to sign in register, or sign out. Mail google.appengine.api.urlfetch rotate(clockwise_degrees) Provides two ways to send an email message: the mail.send_mail() horizontal_flip() function and the EmailMessage class. User represents a user with a Google account. vertical_flip() CONSTRUCTOR EmailMessage represents an email message. im_feeling_lucky() class User(email=None) composite(inputs, width, height, color=0, CONSTRUCTOR INSTANCE METHODS output_encoding=images.PNG) class EmailMessage(**fields) email() string histogram(image_data) list nickname() string INSTANCE METHODS execute_transforms() Image Object check_initialized() user_id() string FUNCTIONS initialize(**fields) This can be the user id of an email address or the full email address if it differs from the They are the same as the instance methods, but they can be performed application’s auth domain (gmail.com or the Google Apps domain for which the applica- is_initialized() bool directly on image_data. There is no need to queue them using execute_trans- tion is registered). forms(). They include an additional parameter which is the expected send() output_encoding image type, which defaults to PNG. FUNCTIONS FUNCTIONS create_login_url(dest_url) string (URL) EXCEPTIONS check_email_valid(email_address, field) create_logout_url(dest_url) string (URL) Error, TransformationError, BadRequestError, This raises an InvalidEmailError when the email_address is invalid. NotImageError, BadImageError, LargeImageError