Cover image for Programming Google App Engine, 2nd Edition

Book description

Google App Engine does more than provide access to a large system of servers. It also offers you a simple model for building applications that scale automatically to accommodate millions of users. With this updated edition of Programming Google App Engine, you'll get expert practical guidance that will help you make the best use of this powerful platform. Google engineer Dan Sanderson shows you how to design your applications for scalability, including ways to perform common development tasks using App Engine's APIs and scalable services.

Table of Contents

  1. Programming Google App Engine
  2. Dedication
  3. Preface
    1. Using This Book
    2. Conventions Used in This Book
    3. Using Code Samples
    4. Safari® Books Online
    5. How to Contact Us
    6. Acknowledgments
  4. 1. Introducing Google App Engine
    1. The Runtime Environment
    2. The Static File Servers
    3. The Datastore
      1. Entities and Properties
      2. Queries and Indexes
      3. Transactions
    4. The Services
    5. Namespaces
    6. Google Accounts, OpenID, and OAuth
    7. Task Queues and Cron Jobs
    8. Developer Tools
    9. The Administration Console
    10. Things App Engine Doesn’t Do...Yet
    11. Getting Started
  5. 2. Creating an Application
    1. Setting Up the SDK
      1. Installing the Python SDK
        1. A brief tour of the Launcher
      2. Installing the Java SDK
        1. Java on Mac OS X
        2. Installing the Java SDK with the Google Plugin for Eclipse
        3. Installing the Java SDK without Eclipse
    2. Developing the Application
      1. The User Preferences Pattern
      2. Developing a Python App
        1. Introducing the webapp framework
        2. Users and Google Accounts
        3. Web forms and the datastore
        4. Caching with memcache
      3. Developing a Java App
        1. Introducing JSPs, JSTL, and EL
        2. Users and Google Accounts
        3. Web forms and the datastore
        4. Caching with memcache
      4. The Development Console
        1. The Python Interactive Console
    3. Registering the Application
      1. The Application ID and Title
      2. Setting Up a Domain Name
      3. Google Apps and Authentication
    4. Uploading the Application
      1. Using Two-Step Verification
    5. Introducing the Administration Console
  6. 3. Configuring an Application
    1. The App Engine Architecture
    2. Configuring a Python App
      1. Runtime Versions
    3. Configuring a Java App
    4. Domain Names
    5. App IDs and Versions
      1. App IDs and Versions in Python
      2. App IDs and Versions in Java
    6. Multithreading
    7. Request Handlers
      1. Request Handlers in Python
      2. Request Handlers in Java
    8. Static Files and Resource Files
      1. Static Files in Python
        1. MIME types
        2. Cache expiration
      2. Static Files in Java
    9. Secure Connections
      1. Secure Connections in Python
      2. Secure Connections in Java
    10. Authorization with Google Accounts
      1. Authorization in Python
      2. Authorization in Java
    11. Environment Variables
    12. Inbound Services
    13. Custom Error Responses
    14. Administration Console Custom Pages
    15. More Python Features
      1. Python Libraries
      2. Built-in Handlers
      3. Includes
    16. Java Servlet Sessions
  7. 4. Request Handlers and Instances
    1. The Runtime Environment
      1. The Sandbox
      2. Quotas and Limits
        1. Request limits
        2. Service limits
        3. Deployment limits
        4. Billable quotas
      3. The Python Runtime Environment
      4. The Java Runtime Environment
    2. The Request Handler Abstraction
    3. Introducing Instances
    4. Request Scheduling and Pending Latency
    5. Warm-up Requests
    6. Resident Instances
    7. The Instances Console
    8. Instance Hours and Billing
    9. Instance Classes
  8. 5. Datastore Entities
    1. Entities, Keys, and Properties
    2. Introducing the Python Datastore API
    3. Introducing the Java Datastore API
    4. Property Values
      1. Strings, Text, and Blobs
      2. Unset Versus the Null Value
      3. Multivalued Properties
    5. Keys and Key Objects
    6. Using Entities
      1. Getting Entities Using Keys
      2. Inspecting Entity Objects
      3. Saving Entities
      4. Deleting Entities
    7. Allocating System IDs
    8. The Development Server and the Datastore
  9. 6. Datastore Queries
    1. Queries and Kinds
    2. Query Results and Keys
    3. GQL
    4. The Python Query API
      1. The Query Class
      2. GQL in Python
      3. Retrieving Results
      4. Keys-Only Queries
    5. The Java Query API
      1. Building the Query
      2. Fetching Results with PreparedQuery
      3. Keys-Only Queries in Java
    6. Introducing Indexes
    7. Automatic Indexes and Simple Queries
      1. All Entities of a Kind
      2. One Equality Filter
      3. Greater-Than and Less-Than Filters
      4. One Sort Order
      5. Queries on Keys
      6. Kindless Queries
    8. Custom Indexes and Complex Queries
      1. Multiple Sort Orders
      2. Filters on Multiple Properties
      3. Multiple Equality Filters
    9. Not-Equal and IN Filters
    10. Unset and Nonindexed Properties
    11. Sort Orders and Value Types
    12. Queries and Multivalued Properties
      1. A Simple Example
      2. MVPs in Python
      3. MVPs in Java
      4. MVPs and Equality Filters
      5. MVPs and Inequality Filters
      6. MVPs and Sort Orders
      7. Exploding Indexes
    13. Query Cursors
      1. Cursors in Python
      2. Cursors in Java
    14. Projection Queries
      1. Projection Queries in Python
      2. Projection Queries in Java
    15. Configuring Indexes
      1. Index Configuration for Python
      2. Index Configuration for Java
  10. 7. Datastore Transactions
    1. Entities and Entity Groups
      1. Keys, Paths, and Ancestors
      2. Ancestor Queries
    2. What Can Happen in a Transaction
      1. Transactional Reads
      2. Eventually Consistent Reads
    3. Transactions in Python
    4. Transactions in Java
    5. How Entities Are Updated
    6. How Entities Are Read
    7. Batch Updates
    8. How Indexes Are Updated
    9. Cross-Group Transactions
  11. 8. Datastore Administration
    1. Inspecting the Datastore
    2. Managing Indexes
    3. The Datastore Admin Panel
    4. Accessing Metadata from the App
      1. Querying Statistics
      2. Querying Metadata
      3. Index Status and Queries
      4. Entity Group Versions
    5. Remote Controls
      1. Setting Up the Remote API for Python
      2. Setting Up the Remote API for Java
      3. Using the Remote Shell Tool
      4. Using the Remote API from a Script
  12. 9. Data Modeling with Python
    1. Models and Properties
    2. Property Declarations
      1. Property Value Types
      2. Property Validation
      3. Nonindexed Properties
      4. Automatic Values
      5. List Properties
      6. Models and Schema Migration
    3. Modeling Relationships
      1. One-to-Many Relationships
      2. One-to-One Relationships
      3. Many-to-Many Relationships
        1. The key list method
        2. The link model method
    4. Model Inheritance
    5. Queries and PolyModels
    6. Creating Your Own Property Classes
      1. Validating Property Values
      2. Marshaling Value Types
      3. Customizing Default Values
      4. Accepting Arguments
  13. 10. The Java Persistence API
    1. Setting Up JPA
    2. Entities and Keys
    3. Entity Properties
    4. Embedded Objects
    5. Saving, Fetching, and Deleting Objects
    6. Transactions in JPA
    7. Queries and JPQL
    8. Relationships
    9. For More Information
  14. 11. The Memory Cache
    1. Calling Memcache from Python
    2. Calling Memcache from Java
    3. Keys and Values
    4. Setting Values
      1. Setting Values that Expire
      2. Adding and Replacing Values
    5. Getting Values
    6. Deleting Values
      1. Locking a Deleted Key
    7. Atomic Increment and Decrement
    8. Compare and Set
    9. Batching Calls to Memcache
      1. Memcache Batch Calls in Python
      2. Memcache Batch Calls in Java
    10. Memcache and the Datastore
    11. Handling Memcache Errors
    12. Memcache Administration
      1. Cache Statistics
      2. Flushing the Memcache
  15. 12. Large Data and the Blobstore
    1. Accepting User Uploads
      1. Web Forms and MIME Multipart Data
      2. Blobstore Upload Requests
      3. Handling Uploads in Python
      4. Handling Uploads in Java
    2. Using BlobInfo Entities
      1. Using BlobInfo Entities in Python
      2. Using BlobInfo Entities in Java
    3. Serving Blobstore Values
      1. Serving Blobstore Values in Python
      2. Serving Blobstore Values in Java
    4. Deleting Blobstore Values
    5. Reading Blobstore Values
      1. Fetching Byte Ranges
      2. Reading Values with Streams
    6. A Complete Example
      1. A Blobstore Example in Python
      2. A Blobstore Example in Java
  16. 13. Fetching URLs and Web Resources
    1. Fetching URLs in Python
    2. Fetching URLs in Java
    3. Outgoing HTTP Requests
      1. The URL
      2. The HTTP Method and Payload
      3. Request Headers
    4. HTTP Over SSL (HTTPS)
    5. Request and Response Sizes
    6. Request Deadlines
    7. Handling Redirects
    8. Response Objects
  17. 14. Sending and Receiving Email Messages
    1. Sending Email Messages
      1. Sending Email from the Development Server
      2. Sender Addresses
      3. Recipients
      4. Attachments
      5. Sending Email in Python
      6. Sending Email in Java
    2. Receiving Email Messages
      1. Receiving Email in Python
      2. Receiving Email in Java
  18. 15. Sending and Receiving Instant Messages with XMPP
    1. Inviting a User to Chat
      1. Sending Invitations in Python
      2. Sending Invitations in Java
    2. Sending Chat Messages
      1. Sending Chat Messages in Python
      2. Sending Chat Messages in Java
    3. Receiving Chat Messages
      1. Receiving Chat Messages in Python
        1. Handling Commands over Chat in Python
      2. Receiving Chat Messages in Java
    4. Handling Error Messages
    5. Managing Presence
      1. Managing Subscriptions
        1. Subscriptions in Python
        2. Subscriptions in Java
      2. Managing Presence Updates
        1. Presence in Python
        2. Presence in Java
      3. Probing for Presence
        1. Presence probes in Python
        2. Presence probes in Java
      4. Checking a Google Talk User’s Status
  19. 16. Task Queues and Scheduled Tasks
    1. Configuring Task Queues
    2. Enqueuing a Task
      1. Enqueuing a Task in Python
      2. Enqueuing a Task in Java
    3. Task Parameters
      1. Payloads
      2. Task Names
      3. Countdowns and ETAs
    4. Push Queues
      1. Task Requests
      2. Processing Rates and Token Buckets
      3. Retrying Push Tasks
    5. Pull Queues
      1. Enqueuing Tasks to Pull Queues
      2. Leasing and Deleting Tasks
      3. Retrying Pull Queue Tasks
    6. Transactional Task Enqueueing
      1. Transactional Tasks in Python
      2. Transactional Tasks in Java
    7. Task Chaining
    8. Task Queue Administration
    9. Deferring Work
      1. Deferring Work in Python
      2. Deferring Work in Java
    10. Scheduled Tasks
      1. Configuring Scheduled Tasks
      2. Specifying Schedules
  20. 17. Optimizing Service Calls
    1. Calling Services Asynchronously
      1. Asynchronous Calls in Python
        1. Datastore
        2. Memcache
        3. Blobstore
        4. URL Fetch
        5. Using callbacks
      2. Asynchronous Calls in Java
        1. Datastore
        2. Memcache
        3. URL Fetch
    2. Visualizing Calls with AppStats
      1. Installing AppStats for Python
      2. Installing AppStats for Java
      3. Using the AppStats Console
  21. 18. The Django Web Application Framework
    1. Using the Bundled Django Library
    2. Creating a Django Project
    3. Hooking It Up to App Engine
    4. Creating a Django App
    5. Using Django Templates
    6. Using Django Forms
    7. The django-nonrel Project
  22. 19. Managing Request Logs
    1. Writing to the Log
      1. Logging in Python
      2. Logging in Java
    2. Viewing Recent Logs
    3. Downloading Logs
    4. Logs Retention
    5. Querying Logs from the App
      1. Querying Logs in Python
      2. Querying Logs in Java
    6. Flushing the Log Buffer
  23. 20. Deploying and Managing Applications
    1. Uploading an Application
    2. Using Versions
    3. Managing Service Configuration
    4. Application Settings
    5. Managing Developers
    6. Quotas and Billing
    7. Getting Help
  24. Index
  25. About the Author
  26. Colophon
  27. Copyright