SlideShare una empresa de Scribd logo
1 de 18
Google App Engine入門課程



     國網中心格網技術組
 專案助理研究員 鄭宗碩, Zong-shuo Jheng
     zsjheng@nchc.org.tw
 參考網頁: http://nchc-gae.blogspot.com
Outline
•   What is Google App Engine
•   Prerequirements for a new pilot
•   Hello Google App Engine!
•   Pieces of a flying GAE
•   Data-storing black box - Google DataStore




      NCHC, Google App Engine experience course. 2009
What is Google App Engine
• Hosting services on Google cloud platform
• Benefited by Google File System, BigTable
• Free for limited accessing
  (10 free Web AP, up to 500MB of storage, up to 5 million page views a month, 2
  billion CPU clock cycles one day)




       NCHC, Google App Engine experience course. 2009
Outline
•   What is Google App Engine
•   Prerequirements for a new pilot
•   Hello Google App Engine!
•   Pieces of a flying GAE
•   Data-storing black box - Google DataStore




      NCHC, Google App Engine experience course. 2009
Prerequirements for a new pilot
• Python runtime
  http://python.org/

• Google App Engine SDK
  http://code.google.com/appengine/
  ~/:> upzip google_appengine_1.2.2.zip
  appcfg.py, dev_appserver.py

• Eclipse with PyDev
  http://nchc-gae.blogspot.com/2009/05/eclipse-pydev-google-app-engine.html


• Applying for a free account
  http://nchc-gae.blogspot.com/2009/05/google-app-engine.html




        NCHC, Google App Engine experience course. 2009
Outline
•   What is Google App Engine
•   Prerequirements for a new pilot
•   Hello Google App Engine!
•   Pieces of a flying GAE
•   Storing data in Google DataStore




      NCHC, Google App Engine experience course. 2009
Hello Google App Engine!
<<app.yaml>>             << hello.py >>
application: HelloGAE    from google.appengine.ext import webapp
version: 1               from google.appengine.ext.webapp.util import run_wsgi_app
runtime: python
api_version: 1           class MainPage(webapp.RequestHandler):
                          def get(self):
handlers:                   self.response.headers['Content-Type'] = 'text/html; charset=UTF-8'
- url: /.*                  self.response.out.write(quot;Hello Google App Engine!quot;)
  script: hello.py
                         application = webapp.WSGIApplication([('/', MainPage)],
                                                              debug=True)
                         def main():
                          run_wsgi_app(application)

                         if __name__ == quot;__main__quot;:
                           main()

              NCHC, Google App Engine experience course. 2009
Outline
•   What is Google App Engine
•   Prerequirements for a new pilot
•   Hello Google App Engine!
•   Pieces of a flying GAE
•   Data-storing black box - Google DataStore




      NCHC, Google App Engine experience course. 2009
Pieces of a flying GAE
•   Configuration files
•   MVC design pattern
•   webapp framework
•   Template
•   Google User service API
•   Dashboard



      NCHC, Google App Engine experience course. 2009
Configuration files
• app.yaml
• cron.yaml
• index.yaml




    NCHC, Google App Engine experience course. 2009
MVC design pattern
<<User-defined Handler class>>                          <<DataStore>>
Eg. class Main_handler(webapp.RequestHandler)           from google.appengine.ext
                                                        import db




                                                 <<Template>>
                                                 from google.appengine.ext.webapp
                                                 import template




           NCHC, Google App Engine experience course. 2009
webapp framework
<< hello.py >>
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
 def get(self):                                                         3
   self.response.headers['Content-Type'] = 'text/html; charset=UTF-8'
   self.response.out.write(quot;Hello Google App Engine!quot;)

application = webapp.WSGIApplication([('/', MainPage)],
                                     debug=True)
def main():                    2                                        3
 run_wsgi_app(application)                          1           2
                                         1
if __name__ == quot;__main__quot;:
  main()


  NCHC, Google App Engine experience course. 2009
Template
Reference : http://nchc-gae.blogspot.com/2009/05/google-app-engine-template-tutorial.html

 <<template/index.htm>>
 <html>
  <head><title>Hello Template</title></head>
  <body> {{ Welcome_msg }} </body>
 </html>

 <<index.py>>
 import os
 from google.appengine.ext.webapp import template

 class Main_handler(webapp.RequestHandler):
      def get(self):
           template_value = { 'Welcome_msg': 'Hello, Template!' }
           path = os.path.join(os.path.dirname(__file__),'template/index.htm')
           outstr = template.render(path, template_value)
           self.response.out.write(outstr)
          NCHC, Google App Engine experience course. 2009
Google User service API
                 from google.appengine.api import users
                                                                 create_login_url(dest_url)
User class:                                                      create_logout_url(dest_url)
                 class MyHandler(webapp.RequestHandler):
 email                                                           get_current_user()
                   def get(self):
 nickname()                                                      is_current_user_admin()
                     user = users.get_current_user()
 email()             if user:
 user_id()            greeting = (quot;Welcome, %s! (<a href=quot;%squot;>sign out</a>)quot; %
                                   (user.nickname(), users.create_logout_url(quot;/quot;)))
                    else:
                       greeting = (quot;<a href=quot;%squot;>Sign in or register</a>.quot; %
                                    users.create_login_url(quot;/quot;))
                    self.response.out.write(quot;<html><body>%s</body></html>quot; % greeting)

                 user = users.get_current_user()
                 if user:
                    print quot;Welcome, %s!quot; % user.nickname()
                    if users.is_current_user_admin():
                      print quot;<a href=quot;/admin/quot;>Go to admin area</a>quot;
              NCHC, Google App Engine experience course. 2009
Outline
•   What is Google App Engine
•   Prerequirements for a new pilot
•   Hello Google App Engine!
•   Pieces of a flying GAE
•   Data-storing black box - Google DataStore




      NCHC, Google App Engine experience course. 2009
Data-storing black box - Google DataStore
 • Types and Property Classes
   http://code.google.com/intl/en/appengine/docs/python/datastore/typesandpropertyclasses.html

 • Entity and Model
        from google.appengine.ext import db

        class Pet(db.Model):
         name = db.StringProperty(required=True)
         type = db.StringProperty(required=True, choices=set([quot;catquot;, quot;dogquot;, quot;birdquot;]))
         birthdate = db.DateProperty()
         weight_in_pounds = db.IntegerProperty()

        pet = Pet(name=quot;Fluffyquot;,
              type=quot;catquot;,
              owner=users.get_current_user())
        pet.weight_in_pounds = 24
         NCHC, Google App Engine experience course. 2009
Data-storing black box - Google DataStore
 • Creating and Deleting Data
   pet.put() / db.put(pet), pet.delete() / db.delete(pet)

 • Getting data
   class Story(db.Model):
     title = db.StringProperty()
     date = db.DateTimeProperty()
   query = Story.all()
   query.filter('title =', 'Foo')
   query.order('-date')
   query.ancestor(key)

   query.filter('title =', 'Foo').order('-date').ancestor(key)


       NCHC, Google App Engine experience course. 2009
Data-storing black box - Google DataStore
   query = db.GqlQuery(quot;SELECT * FROM Story WHERE title = :1 quot;
              quot;AND ANCESTOR IS :2 quot;
              quot;ORDER BY date DESCquot;,
              'Foo', key)

   query = Story.gql(quot;WHERE title = :title quot;
             quot;AND ANCESTOR IS :parent quot;
             quot;ORDER BY date DESCquot;,
             title='Foo', parent=key)




       NCHC, Google App Engine experience course. 2009

Más contenido relacionado

La actualidad más candente

Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.jsTechExeter
 
Testing C# and ASP.net using Ruby
Testing C# and ASP.net using RubyTesting C# and ASP.net using Ruby
Testing C# and ASP.net using RubyBen Hall
 
Arquitetura de Front-end em Aplicações de Larga Escala
Arquitetura de Front-end em Aplicações de Larga EscalaArquitetura de Front-end em Aplicações de Larga Escala
Arquitetura de Front-end em Aplicações de Larga EscalaEduardo Shiota Yasuda
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법Jeado Ko
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Desbravando Web Components
Desbravando Web ComponentsDesbravando Web Components
Desbravando Web ComponentsMateus Ortiz
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applicationsAstrails
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS InternalEyal Vardi
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2giwoolee
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS DirectivesEyal Vardi
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuffjeresig
 

La actualidad más candente (20)

Angular js
Angular jsAngular js
Angular js
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Enjoy the vue.js
Enjoy the vue.jsEnjoy the vue.js
Enjoy the vue.js
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
 
Testing C# and ASP.net using Ruby
Testing C# and ASP.net using RubyTesting C# and ASP.net using Ruby
Testing C# and ASP.net using Ruby
 
Arquitetura de Front-end em Aplicações de Larga Escala
Arquitetura de Front-end em Aplicações de Larga EscalaArquitetura de Front-end em Aplicações de Larga Escala
Arquitetura de Front-end em Aplicações de Larga Escala
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Modular and Event-Driven JavaScript
Modular and Event-Driven JavaScriptModular and Event-Driven JavaScript
Modular and Event-Driven JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Desbravando Web Components
Desbravando Web ComponentsDesbravando Web Components
Desbravando Web Components
 
Building and deploying React applications
Building and deploying React applicationsBuilding and deploying React applications
Building and deploying React applications
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
AngularJS Framework
AngularJS FrameworkAngularJS Framework
AngularJS Framework
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS Internal
 
WordPress plugin #2
WordPress plugin #2WordPress plugin #2
WordPress plugin #2
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
AngularJS Directives
AngularJS DirectivesAngularJS Directives
AngularJS Directives
 
jQuery Internals + Cool Stuff
jQuery Internals + Cool StuffjQuery Internals + Cool Stuff
jQuery Internals + Cool Stuff
 

Similar a Gae

OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010ikailan
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con pythonsserrano44
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplicationolegmmiller
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4Javier Eguiluz
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0Matt Raible
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
I've (probably) been using Google App Engine for a week longer than you have
I've (probably) been using Google App Engine for a week longer than you haveI've (probably) been using Google App Engine for a week longer than you have
I've (probably) been using Google App Engine for a week longer than you haveSimon Willison
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesTikal Knowledge
 
The Google App Engine Oil Framework
The Google App Engine Oil FrameworkThe Google App Engine Oil Framework
The Google App Engine Oil FrameworkEric ShangKuan
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3Javier Eguiluz
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munichdion
 
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...Singapore Google Technology User Group
 
Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Steve Souders
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project ManagementWidoyo PH
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gearsdion
 

Similar a Gae (20)

OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 
Introduccion app engine con python
Introduccion app engine con pythonIntroduccion app engine con python
Introduccion app engine con python
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
What's Coming in Spring 3.0
What's Coming in Spring 3.0What's Coming in Spring 3.0
What's Coming in Spring 3.0
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
I've (probably) been using Google App Engine for a week longer than you have
I've (probably) been using Google App Engine for a week longer than you haveI've (probably) been using Google App Engine for a week longer than you have
I've (probably) been using Google App Engine for a week longer than you have
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
The Google App Engine Oil Framework
The Google App Engine Oil FrameworkThe Google App Engine Oil Framework
The Google App Engine Oil Framework
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
App Engine On Air: Munich
App Engine On Air: MunichApp Engine On Air: Munich
App Engine On Air: Munich
 
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
Talk 1: Google App Engine Development: Java, Data Models, and other things yo...
 
Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09Even Faster Web Sites at jQuery Conference '09
Even Faster Web Sites at jQuery Conference '09
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project Management
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 

Gae

  • 1. Google App Engine入門課程 國網中心格網技術組 專案助理研究員 鄭宗碩, Zong-shuo Jheng zsjheng@nchc.org.tw 參考網頁: http://nchc-gae.blogspot.com
  • 2. Outline • What is Google App Engine • Prerequirements for a new pilot • Hello Google App Engine! • Pieces of a flying GAE • Data-storing black box - Google DataStore NCHC, Google App Engine experience course. 2009
  • 3. What is Google App Engine • Hosting services on Google cloud platform • Benefited by Google File System, BigTable • Free for limited accessing (10 free Web AP, up to 500MB of storage, up to 5 million page views a month, 2 billion CPU clock cycles one day) NCHC, Google App Engine experience course. 2009
  • 4. Outline • What is Google App Engine • Prerequirements for a new pilot • Hello Google App Engine! • Pieces of a flying GAE • Data-storing black box - Google DataStore NCHC, Google App Engine experience course. 2009
  • 5. Prerequirements for a new pilot • Python runtime http://python.org/ • Google App Engine SDK http://code.google.com/appengine/ ~/:> upzip google_appengine_1.2.2.zip appcfg.py, dev_appserver.py • Eclipse with PyDev http://nchc-gae.blogspot.com/2009/05/eclipse-pydev-google-app-engine.html • Applying for a free account http://nchc-gae.blogspot.com/2009/05/google-app-engine.html NCHC, Google App Engine experience course. 2009
  • 6. Outline • What is Google App Engine • Prerequirements for a new pilot • Hello Google App Engine! • Pieces of a flying GAE • Storing data in Google DataStore NCHC, Google App Engine experience course. 2009
  • 7. Hello Google App Engine! <<app.yaml>> << hello.py >> application: HelloGAE from google.appengine.ext import webapp version: 1 from google.appengine.ext.webapp.util import run_wsgi_app runtime: python api_version: 1 class MainPage(webapp.RequestHandler): def get(self): handlers: self.response.headers['Content-Type'] = 'text/html; charset=UTF-8' - url: /.* self.response.out.write(quot;Hello Google App Engine!quot;) script: hello.py application = webapp.WSGIApplication([('/', MainPage)], debug=True) def main(): run_wsgi_app(application) if __name__ == quot;__main__quot;: main() NCHC, Google App Engine experience course. 2009
  • 8. Outline • What is Google App Engine • Prerequirements for a new pilot • Hello Google App Engine! • Pieces of a flying GAE • Data-storing black box - Google DataStore NCHC, Google App Engine experience course. 2009
  • 9. Pieces of a flying GAE • Configuration files • MVC design pattern • webapp framework • Template • Google User service API • Dashboard NCHC, Google App Engine experience course. 2009
  • 10. Configuration files • app.yaml • cron.yaml • index.yaml NCHC, Google App Engine experience course. 2009
  • 11. MVC design pattern <<User-defined Handler class>> <<DataStore>> Eg. class Main_handler(webapp.RequestHandler) from google.appengine.ext import db <<Template>> from google.appengine.ext.webapp import template NCHC, Google App Engine experience course. 2009
  • 12. webapp framework << hello.py >> from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self): 3 self.response.headers['Content-Type'] = 'text/html; charset=UTF-8' self.response.out.write(quot;Hello Google App Engine!quot;) application = webapp.WSGIApplication([('/', MainPage)], debug=True) def main(): 2 3 run_wsgi_app(application) 1 2 1 if __name__ == quot;__main__quot;: main() NCHC, Google App Engine experience course. 2009
  • 13. Template Reference : http://nchc-gae.blogspot.com/2009/05/google-app-engine-template-tutorial.html <<template/index.htm>> <html> <head><title>Hello Template</title></head> <body> {{ Welcome_msg }} </body> </html> <<index.py>> import os from google.appengine.ext.webapp import template class Main_handler(webapp.RequestHandler): def get(self): template_value = { 'Welcome_msg': 'Hello, Template!' } path = os.path.join(os.path.dirname(__file__),'template/index.htm') outstr = template.render(path, template_value) self.response.out.write(outstr) NCHC, Google App Engine experience course. 2009
  • 14. Google User service API from google.appengine.api import users create_login_url(dest_url) User class: create_logout_url(dest_url) class MyHandler(webapp.RequestHandler): email get_current_user() def get(self): nickname() is_current_user_admin() user = users.get_current_user() email() if user: user_id() greeting = (quot;Welcome, %s! (<a href=quot;%squot;>sign out</a>)quot; % (user.nickname(), users.create_logout_url(quot;/quot;))) else: greeting = (quot;<a href=quot;%squot;>Sign in or register</a>.quot; % users.create_login_url(quot;/quot;)) self.response.out.write(quot;<html><body>%s</body></html>quot; % greeting) user = users.get_current_user() if user: print quot;Welcome, %s!quot; % user.nickname() if users.is_current_user_admin(): print quot;<a href=quot;/admin/quot;>Go to admin area</a>quot; NCHC, Google App Engine experience course. 2009
  • 15. Outline • What is Google App Engine • Prerequirements for a new pilot • Hello Google App Engine! • Pieces of a flying GAE • Data-storing black box - Google DataStore NCHC, Google App Engine experience course. 2009
  • 16. Data-storing black box - Google DataStore • Types and Property Classes http://code.google.com/intl/en/appengine/docs/python/datastore/typesandpropertyclasses.html • Entity and Model from google.appengine.ext import db class Pet(db.Model): name = db.StringProperty(required=True) type = db.StringProperty(required=True, choices=set([quot;catquot;, quot;dogquot;, quot;birdquot;])) birthdate = db.DateProperty() weight_in_pounds = db.IntegerProperty() pet = Pet(name=quot;Fluffyquot;, type=quot;catquot;, owner=users.get_current_user()) pet.weight_in_pounds = 24 NCHC, Google App Engine experience course. 2009
  • 17. Data-storing black box - Google DataStore • Creating and Deleting Data pet.put() / db.put(pet), pet.delete() / db.delete(pet) • Getting data class Story(db.Model): title = db.StringProperty() date = db.DateTimeProperty() query = Story.all() query.filter('title =', 'Foo') query.order('-date') query.ancestor(key) query.filter('title =', 'Foo').order('-date').ancestor(key) NCHC, Google App Engine experience course. 2009
  • 18. Data-storing black box - Google DataStore query = db.GqlQuery(quot;SELECT * FROM Story WHERE title = :1 quot; quot;AND ANCESTOR IS :2 quot; quot;ORDER BY date DESCquot;, 'Foo', key) query = Story.gql(quot;WHERE title = :title quot; quot;AND ANCESTOR IS :parent quot; quot;ORDER BY date DESCquot;, title='Foo', parent=key) NCHC, Google App Engine experience course. 2009