The Google App Engine Oil Framework

2,666 views
2,529 views

Published on

Intro to GAEO framework

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,666
On SlideShare
0
From Embeds
0
Number of Embeds
29
Actions
Shares
0
Downloads
31
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

The Google App Engine Oil Framework

  1. 1. The Google App Engine Oil (GAEO) Framework Lin-Chieh Shangkuan (ericsk)
  2. 2. Outline Google App Engine overview Why we develop the GAEO framework What's done in GAEO 0.1 GAEO's current & future features How to start using GAEO (DEMO) GAEO links Q&A
  3. 3. Current Google App Engine An application server with pure Python runtime language also a web server for you (HTTP) Request-based environment Uses BigTable as database Application version control and seamless upgrades/degrades. HTTPS support (*.appspot.com only)
  4. 4. Developing Applications on AppEngine
  5. 5. Request-based Configuration ctrl_list = ['Tag', 'User', 'Ziza'] app = webapp.WSGIApplication([ ('/', IndexView), ('/home', HomeView), ('/explore', ExploreView), ('/replies', RepliesView), ('/signup', SignupView), ('/settings', SettingsView), ('/tags', TagsView), ('/m/([^/s]*)', MsgView), ('/f/([^/s]*)', FeedsView), ('/r/([^/s]*)', FeedsWithFriendsView), ('/u/([^/s]*)', UserView), ('/t/([^/s]*)', TagView), ] + [(r'/%s/(.*)' % s.lower(), eval(s + 'Controller')) for s in ctrl_list], debug=True)
  6. 6. Handle HTTP Request class IndexView(webapp.RequestHandler): def get(self): # get the user object user = users.get_current_user() if user: # the user has logined self.redirect('/home') template_values = { 'signin_url': users.create_login_url('/home'), }
  7. 7. Deployment
  8. 8. Why do we develop a framework on AppEngine?
  9. 9. Goal To be familiar with AppEngine Convention over configuration Structured, meaningful, parameterized URL More helper methods Quickly migrate from ZF or Rails For team works
  10. 10. Software Architecture action action client dispatcher request . dispatch . . action response
  11. 11. Code Layout (0.2) $APP_BASE/ application/ controllers/ models/ templates/ assets/ css/ img/ js/ gaeo/ plugins/ app.yaml favicon.ico main.py
  12. 12. GAEO 0.1 released at Sep. 19, 2008
  13. 13. GAEO URL Routing Default: http://example.com/foo/bar/1234 controller: foo (FooController class)action: bar (bar method in FooController)id: 1234 Configurable & Parameterize: route.connect('/signin', controller='account', action='signin') route.connect('/user/:name', controller='user', action='show') route.connect('/foo/:action/:x/:y/:z', controller='foo')
  14. 14. Action Controller Each request is distributed to an action In GAEO, an action is a method of an action controller Create a controller class that extends gaeo.controller. BaseController Implement the action class FooController(BaseController): def bar(self): quot;quot;quot; TODO: do things for /foo/bar request quot;quot;quot; pass
  15. 15. Response Helper Use to_json method (uses simplejson) to convert a dict instance to a JSON string Use render method to output different response data. (helps set the Content-Type header) Use redirect method to redirect to another action (or URL) Do something in before_action and after_action filters
  16. 16. Session support Store data at server (mapping clients via Session-IDs that stores in cookies) GAEO has designed a session interface and a memcache- session implementation. Use self.session in the actions.
  17. 17. Model enhancement Add some helper methods update_attributes save, update Naming query A beginning of ORM belongs_to method
  18. 18. Other helpers Object shortcuts: request response cookies Mobile device detection _is_iphone _is_mobile
  19. 19. GAEO 0.2 beta released at Oct. 31, 2008
  20. 20. Setuptools support Now you can use easy_install gaeo to install the GAEO package. Also available on pypi http://pypi.python.org/pypi/gaeo Provided by gasolin
  21. 21. Scaffold Quickly generates some common pages new list show edit create update destroy Provided by xeonchen
  22. 22. Plugins Provides plugins system in GAEO Install features on demand 3rd party development :-p
  23. 23. Other Enhancements Global initialization application_init method (in ApplicationController) AJAX/Form helpers generates some useful AJAX/form strings The respond_to method respond content according to :format parameter zip core import You can zip the GAEO core to eliminate disk space cost methods enhancements
  24. 24. GAEO's Future future
  25. 25. Roadmap RESTful mobile device support i18n new template rendering engine ...
  26. 26. GAEO Links Document: http://doc.gaeo.org/ Project: http://code.google.com/p/google-app-engine-oil Blog: http://blog.gaeo.org/ Groups: http://groups.google.com/group/google-app-engine-oil
  27. 27. Q&A 感謝您的收聽 Thanks for you attendance ご清聴とうもありがとうございました

×