the google app engine oil framework

27
The Google App Engine Oil (GAEO) Framework Lin-Chieh Shangkuan (ericsk)

Upload: lin-chieh-shangkuan

Post on 14-May-2015

2.361 views

Category:

Design


1 download

DESCRIPTION

Intro to GAEO framework

TRANSCRIPT

Page 1: The Google App Engine Oil Framework

The Google App Engine Oil (GAEO) Framework

Lin-Chieh Shangkuan (ericsk)

Page 2: The Google App Engine Oil Framework

Outline

Google App Engine overviewWhy we develop the GAEO frameworkWhat's done in GAEO 0.1GAEO's current & future featuresHow to start using GAEO (DEMO)GAEO linksQ & A

Page 3: The Google App Engine Oil Framework

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)

Page 4: The Google App Engine Oil Framework

Developing Applications onAppEngine

Page 5: The Google App Engine Oil Framework

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)

Page 6: The Google App Engine Oil Framework

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'), }

Page 7: The Google App Engine Oil Framework

Deployment

Page 8: The Google App Engine Oil Framework

Why do we develop a framework on AppEngine?

Page 9: The Google App Engine Oil Framework

GoalTo be familiar with AppEngineConvention over configuration

Structured, meaningful, parameterized URL

More helper methodsQuickly migrate from ZF or RailsFor team works

Page 10: The Google App Engine Oil Framework

Software Architecture

.

.

.

action

action

action

dispatcherclient

requestdispatch

response

Page 11: The Google App Engine Oil Framework

Code Layout (0.2)$APP_BASE/ application/ controllers/ models/ templates/ assets/ css/ img/ js/ gaeo/ plugins/ app.yaml favicon.ico main.py

Page 12: The Google App Engine Oil Framework

GAEO 0.1released at Sep. 19, 2008

Page 13: The Google App Engine Oil Framework

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')

Page 14: The Google App Engine Oil Framework

Action Controller

Each request is distributed to an actionIn GAEO, an action is a method of an action controller

Create a controller class that extends gaeo.controller.BaseController

Implement the actionclass FooController(BaseController): def bar(self): """ TODO: do things for /foo/bar request """ pass

Page 15: The Google App Engine Oil Framework

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

Page 16: The Google App Engine Oil Framework

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.

Page 17: The Google App Engine Oil Framework

Model enhancement

Add some helper methodsupdate_attributessave, update

Naming query

A beginning of ORMbelongs_to method

Page 18: The Google App Engine Oil Framework

Other helpers

Object shortcuts: requestresponsecookies

Mobile device detection_is_iphone_is_mobile

Page 19: The Google App Engine Oil Framework

GAEO 0.2beta released at Oct. 31, 2008

Page 20: The Google App Engine Oil Framework

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

Page 21: The Google App Engine Oil Framework

Scaffold

Quickly generates some common pagesnewlistshoweditcreateupdatedestroy

Provided by xeonchen

Page 22: The Google App Engine Oil Framework

Plugins

Provides plugins system in GAEO

Install features on demand

3rd party development :-p

Page 23: The Google App Engine Oil Framework

Other Enhancements

Global initializationapplication_init method (in ApplicationController)

AJAX/Form helpersgenerates some useful AJAX/form strings

The respond_to methodrespond content according to :format parameter

zip core importYou can zip the GAEO core to eliminate disk space cost

methods enhancements

Page 24: The Google App Engine Oil Framework

GAEO's Future future

Page 25: The Google App Engine Oil Framework

Roadmap

RESTfulmobile device support i18nnew template rendering engine...

Page 26: The Google App Engine Oil Framework

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

Page 27: The Google App Engine Oil Framework

Q & A

感謝您的收聽 Thanks for you attendance

ご清聴とうもありがとうございました