Você está na página 1de 2

Google App Engine Property is the superclass for data model definitions.

Property is the superclass for data model definitions. Query uses objects and methods to prepare queries.
Python SDK 1.1.9 Revision 1.0 03.10.09 Model.all() returns a query object.
Constructor
class Property(verbose_name=None, name=None, Constructor
Datastore google.appengine.ext.db
default=None, required=False, class Query(model_class)
A scalable storage and query engine.
validator=None, choices=None)
Instance Methods
Package Functions Class Attributes
filter(property_operator, value) self
get(key) Model instance data_type
order(property) self
You can also pass multiple keys and it will return multiple Model instances. Instance Methods ancestor(model instance|key) self
put(model_instance) Key object default_value() value
get() model instance or None
You can also pass multiple model instances and it will return multiple keys. validate(value) value or exception
fetch(limit, offset=0) list of model instances
delete(model_instance|key) empty(value) bool
count(limit=None) integer
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
*args, **kwargs) Constructor
StringProperty str Unicode (str is treated as ASCII)
unicode class Key(encoded=None)
Model is the superclass for data model definitions.
ByteStringProperty db.ByteString byte order Class Methods
Constructor
BooleanProperty bool False < True Key.from_path(*args, **kwds)
class Model(parent=None, key_name=None, **kwds)
The following example creates a key for an entity of kind Address with the numeric ID
IntegerProperty int Numeric
Class Methods 9876 whose parent is an entity of kind User with the named key ‘Boris’:
long
get(key) Key object k = Key.from_path(‘User’, ‘Boris’, ‘Address’, 9876)
FloatProperty float Numeric
get_by_id(id, parent=None) Model instance
DateTimeProperty datetime.datetime Chronological Instance Methods
You can also pass multiple ids and it will return multiple Model instances. DateProperty app() Application name (string)
get_by_key_name(key_name, parent=None) see above TimeProperty
kind() Kind (string)
ListProperty list If ascending, by least element; if
You can also pass multiple ids and it will return multiple Model instances. id() Numeric ID (int)
StringListProperty descending, by greatest element
get_or_insert(key_name, **kwds) see above ReferenceProperty db.Key By path elements (kind, ID or name) name() Entity name (string)
SelfReferenceProperty id_or_name() Numeric ID(int) or name (string)
all() Query object
UserProperty user.User By email address
gql(query_string, *args, **kwds) GQLQuery object has_id_or_name() bool

Examples: BlobProperty db.Blob (not orderable) parent() Key

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”)
CategoryProperty db.Category Unicode
Syntax
kind() Kind
LinkProperty db.Link Unicode WHERE <condition> [AND <condition> ...]
properties() dict
ORDER BY <property> [ASC | DESC] [,<property> [ASC | DESC]…]
EmailProperty db.Email Unicode
Instance Methods LIMIT [<offset>,]<count>

key() Key GeoPtProperty db.GeoPt By latitude, then longitude OFFSET <offset>

<condition> := <property> {< | <= | > | >= | = | != } <value>


put() Key IMProperty db.IM Unicode
<condition> := <property> IN <list>
delete()
PhoneNumberProperty db.PhoneNumber Unicode <condition> := ANCESTOR IS <entity or key>
is_saved() bool
PostalAddressProperty db.PostalAddress Unicode <list> := (<value>, …)
parent() Model
Note that :NUMBER and :NAME are substitutions for positional and keyword argu-
RatingProperty db.Rating Unicode
parent_key() Key ments, referrring to *args (starting at 1) and **kwds respectively. See Model.
to_xml() XML gql() for example usage.
is_current_user_admin() bool is_email_valid(email_address) Boolean
Memcache google.appengine.api.memcache
Exceptions send_mail(sender, to, subject, body, **kw)
A distributed in-memory data cache that can be used in front of or in
Error, UserNotFound(), RedirectTooLongError() send_mail_to_admins(sender, subject, body, **kw)
place of persistent storage.
Exceptions
Functions URL Fetch google.appengine.api.urlfetch Error, BadRequestError, InvalidEmailError,
The URLFetch API can retrieve data using HTTP and HTTPS URLs. InvalidAttachmentTypeError, MissingRecipientsError,
set(key, value, time=0, min_compress_len=0) bool
MisssingSenderError, MissingSubjectError,
True means done while False means an error occured. MissingBodyError
Functions
Note that a Memcache key is an arbitrary string, not an instance of db.Key. Message Fields (**fields)
fetch(url, payload=None, method=GET, Response object
set_multi(mapping, time=0, key_prefix=’’, list headers=(), allow_truncated=False, sender, to, cc, bcc, reply_to, subject, body, html,
min_compress_len=0) follow_redirects=True) attachments
get(key) value
Response Objects
get_multi(keys, key_prefix=’’) dict content Images google.appengine.api.images

delete(key, seconds=0) error code The body content of the response. The App Engine image service lets your application manipulate im-
ages using the same infrastructure as Picasa Web.
delete_multi(keys, seconds=0, key_prefix=’’) bool
content_was_truncated
add(key, value, time=0, min_compress_len=0) bool
True if the allow_truncated parameter to fetch() was True and the
Image represents image data to be transformed.
add_multi(mapping, time=0, key_prefix=’’, list response exceeded the maximum response size. In this case, the content attribute
min_compress_len=0) contains the truncated response. Constructor
replace(key, value, time=0, min_compress_len=0) bool status_code class Image(image_data)

replace_multi(mapping, time=0, key_prefix=’’, list The HTTP status code. Properties


min_compress_len=0)
headers width, height
incr(key, delta=1) int, long or None
The HTTP response headers, as a mapping of names to values. Instance Methods
decr(key, delta=1) int, long or None
resize(width=0, height=0)
flush_all() bool Exception Classes
crop(left_x, top_y, right_x, bottom_y)
Error, InvalidURLError, DownloadError,
get_stats() dict
ResponseTooLargeError The four number arguments are multiplied by the image’s width and height to define
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 Mail google.appengine.api.urlfetch (right_x*image_width, bottom_y*image_height).
page to sign in register, or sign out. The mail API provides two ways to send an email message: the mail.
rotate(clockwise_degrees)
send_mail() function and the EmailMessage class.
horizontal_flip()
User represents a user with a Google account. vertical_flip()
EmailMessage represents an email message.
Constructor im_feeling_lucky()
class User(email=None)
Constructor
execute_transforms( Image Object
class EmailMessage(**fields)
out_encoding=images.PNG|JPEG)
Instance Methods
email() string
Instance Methods Functions
check_initialized() They are the same as the instance methods, but they can be performed
nickname() string
initialize(**fields) directly on image_data. There is no need to queue them using execute_trans-
This can be the user id of an email address or the full email address if it differs from the forms(). They include an additional parameter which is the expected
application’s auth domain (gmail.com or the Google Apps domain for which the applica- is_initialized() bool
out_encoding image type, which defaults to PNG.
tion is registered).
send()
Exceptions
Functions Functions
Error, TransformationError, BadRequestError,
create_login_url(dest_url) string (URL) check_email_valid(email_address, field) NotImageError, BadImageError, LargeImageError
create_logout_url(dest_url) string (URL) This raises an InvalidEmailError when the email_address is invalid.
get_current_user() User
invalid_email_reason(email_address, field) string

Você também pode gostar