the google app engine oil framework
DESCRIPTION
Intro to GAEO frameworkTRANSCRIPT
The Google App Engine Oil (GAEO) Framework
Lin-Chieh Shangkuan (ericsk)
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
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)
Developing Applications onAppEngine
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)
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'), }
Deployment
Why do we develop a framework on AppEngine?
GoalTo be familiar with AppEngineConvention over configuration
Structured, meaningful, parameterized URL
More helper methodsQuickly migrate from ZF or RailsFor team works
Software Architecture
.
.
.
action
action
action
dispatcherclient
requestdispatch
response
Code Layout (0.2)$APP_BASE/ application/ controllers/ models/ templates/ assets/ css/ img/ js/ gaeo/ plugins/ app.yaml favicon.ico main.py
GAEO 0.1released at Sep. 19, 2008
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')
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
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
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.
Model enhancement
Add some helper methodsupdate_attributessave, update
Naming query
A beginning of ORMbelongs_to method
Other helpers
Object shortcuts: requestresponsecookies
Mobile device detection_is_iphone_is_mobile
GAEO 0.2beta released at Oct. 31, 2008
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
Scaffold
Quickly generates some common pagesnewlistshoweditcreateupdatedestroy
Provided by xeonchen
Plugins
Provides plugins system in GAEO
Install features on demand
3rd party development :-p
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
GAEO's Future future
Roadmap
RESTfulmobile device support i18nnew template rendering engine...
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
Q & A
感謝您的收聽 Thanks for you attendance
ご清聴とうもありがとうございました