Introduction To Google App Engine

2,988 views

Published on

Google App Engine の概要についてまとめたものです. 私的勉強会で使用.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,988
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
81
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction To Google App Engine

  1. 1. Google App Engine Kosei Moriyama (cou929) Nov, 23, 2009 Wednesday, May 5, 2010
  2. 2. Agenda • Google App Engine • Getting Started • Wednesday, May 5, 2010
  3. 3. Google App Engine Wednesday, May 5, 2010
  4. 4. Web Wednesday, May 5, 2010
  5. 5. • • • • • • • • … Wednesday, May 5, 2010
  6. 6. App Engine • • • • • • • • … Wednesday, May 5, 2010
  7. 7. • Python • Java • JVM • e.g., JRuby • • • App Engine • Google , URL Fetch, Mail, memcache, • Cron Wednesday, May 5, 2010
  8. 8. • App Engine SDK • web • app engine • Python SDK / Java SDK • google Wednesday, May 5, 2010
  9. 9. Getting Started Wednesday, May 5, 2010
  10. 10. • • http://code.google.com/intl/ja/appengine/docs/python/gettingstarted/ Wednesday, May 5, 2010
  11. 11. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  12. 12. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  13. 13. • Python • http://www.python.org/download/ • 2.5 • 3.x • Python SDK • http://code.google.com/intl/ja/appengine/ downloads.html • Path Wednesday, May 5, 2010
  14. 14. • dev_appserver.py • • appcfg.py • app engine Wednesday, May 5, 2010
  15. 15. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  16. 16. Hello World! • • app.yaml • python main.py Wednesday, May 5, 2010
  17. 17. app.yaml • • id, version, runtime ... • • url Wednesday, May 5, 2010
  18. 18. main.py • print Wednesday, May 5, 2010
  19. 19. App Engine web • Wednesday, May 5, 2010
  20. 20. App Engine web • app engine web CGI request CGI app.yaml app engine routing client web server response CGI foo.py bar.py baz.py Wednesday, May 5, 2010
  21. 21. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  22. 22. Webapp • CGI ‣ , • Python CGI • Django, Cherry.py, Pylons, web.py Wednesday, May 5, 2010
  23. 23. Webapp • • • app engine Wednesday, May 5, 2010
  24. 24. 3 • RequestHandler ( ) • , • WSGIApplication • URL • main • CGI WSGIApplication Wednesday, May 5, 2010
  25. 25. main.py • webapp, run_wsgi_app • MainPage • webapp.RequestHandler • def get(self) • GET • response.headers() • response.out.write() • webapp.WSGIApplication() • run_wsgi_app() Wednesday, May 5, 2010
  26. 26. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  27. 27. Google • users import • user.get_current_user() • user • none • self.redirect(dest_uri) • dest_uri • users.create_login_url(dest_uri) • • , dest_uri Wednesday, May 5, 2010
  28. 28. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  29. 29. • def post(self) • POST • request.get(‘name’) • “name” Wednesday, May 5, 2010
  30. 30. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  31. 31. • • • • not RDBMS Wednesday, May 5, 2010
  32. 32. Entity put() application Data Store List of Entity GQL Wednesday, May 5, 2010
  33. 33. Entity • Entity • db.Model • Property key • Property • db.fooProperty() • Key • entity • Data store Wednesday, May 5, 2010
  34. 34. class Pet(db.Model): name = db.StringProperty(required=True) type = db.StringProperty(required=True, choices=set(["cat", "dog", "bird"])) birthdate = db.DateProperty() weight_in_pounds = db.IntegerProperty() spayed_or_neutered = db.BooleanProperty() owner = db.UserProperty(required=True) Wednesday, May 5, 2010
  35. 35. • , put() • greeting = Greeting(author = users.get_current_user(), content = self.request.get('content')) greeting.put() Wednesday, May 5, 2010
  36. 36. GQL • db.GqlQuery("SELECT * FROM Greeting ORDER BY date DESC LIMIT 10") • greetings Greeting • for greeting in greetings: • • db.GqlQuery("SELECT * FROM Greeting ORDER BY date DESC LIMIT 10") • Greeting.gql("ORDER BY date DESC LIMIT 10") • "SELECT * FROM Greeting" ( ) Wednesday, May 5, 2010
  37. 37. • Greeting.all() greetings.filter("author =", users.get_current_user()) greetings.order("-date") • • Greeting.all().filter("author =", users.get_current_user()).order("-date") Wednesday, May 5, 2010
  38. 38. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  39. 39. • EZT, Cheetah, ClearSilver, Quixote, Django • Django Wednesday, May 5, 2010
  40. 40. • template html • template import • template Dictionary • template.render(path, values) Wednesday, May 5, 2010
  41. 41. Django template • {{ variable }} • {% foo %} • {% for * %} • {% if * %} • {% include * %} Wednesday, May 5, 2010
  42. 42. template • Django template • class template • {% extends foo.html %} • {% block bar %} Wednesday, May 5, 2010
  43. 43. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  44. 44. • index.html , • ok • • , css, JavaScript, , Flash Wednesday, May 5, 2010
  45. 45. app.yaml - url: /stylesheets static_dir: stylesheets • /stylesheets/* , stylesheets Wednesday, May 5, 2010
  46. 46. • • Hello World! • Webapp • Google • • • • • Wednesday, May 5, 2010
  47. 47. • • http://appengine.google.com/ • app.yaml • application: ID • • appcfg.py update helloworld/ • • http://application-id.appspot.com Wednesday, May 5, 2010
  48. 48. Wednesday, May 5, 2010
  49. 49. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  50. 50. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  51. 51. memcach • • memchached • key-value store Wednesday, May 5, 2010
  52. 52. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  53. 53. URL Fetch • HTTP/HTTPS , / • Google , Wednesday, May 5, 2010
  54. 54. • urllib, urllib2, httplib • google • app engine api Wednesday, May 5, 2010
  55. 55. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  56. 56. Mail • Wednesday, May 5, 2010
  57. 57. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  58. 58. • • • 1 • • • ( ) Wednesday, May 5, 2010
  59. 59. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  60. 60. Cron • • cron.yaml Wednesday, May 5, 2010
  61. 61. cron.yaml cron: - description: daily summary job url: /tasks/summary schedule: every 24 hours - description: monday morning mailout url: /mail/weekly schedule: every monday of month 09:00 timezone: Australia/NSW Wednesday, May 5, 2010
  62. 62. • every 5 minutes • every 12 hours • 2nd,third mon,wed,thu of march 17:00 • every monday of month 09:00 • 1st monday of sep,oct,nov 17:00 Wednesday, May 5, 2010
  63. 63. app.yaml handlers: - url: /report/weekly script: reports.py login: admin Wednesday, May 5, 2010
  64. 64. • memcache • URL Fetch • Mail • • Cron ( ) • Wednesday, May 5, 2010
  65. 65. • pure python ok • • • Antlr 3 • Django 0.9.6 • PyCrypto • WebOb • YAML • zipimport Wednesday, May 5, 2010
  66. 66. Wednesday, May 5, 2010

×