An Introduction to GAEO web framework

21
An Introduction to GAEO web framework ericsk OSDC.tw 2009

description

The GAEO talk in OSDC.tw 2009

Transcript of An Introduction to GAEO web framework

Page 1: An Introduction to GAEO web framework

An Introduction to GAEO web

framework

ericskOSDC.tw 2009

Page 2: An Introduction to GAEO web framework

Agenda

Google App EngineWhy GAEO?How to use GAEORoadmapLive Demo

Page 3: An Introduction to GAEO web framework

Google App Engine

Host your web application and data (w/ quota limits)

You don't need to maintain the server, focus on your application

Pay for what you use. (no setup fee)Scalable servers and storages

Google's infrastructureCron service (NEW )Both Python and Java (NEW ) are supported

Page 4: An Introduction to GAEO web framework

Google App Engine (cont.)

Dashboard

Page 5: An Introduction to GAEO web framework

Why GAEO?

I need a web framework. webapp is too simple; django is too complicated.

GAEO: Google App Engine OilConvension over configuration.More easily development on GAE to Rails/Zend Framework developers.

Page 6: An Introduction to GAEO web framework

What is GAEO?

Model-Template-Controller -based web framework.based on webappinspired from Rails/Zend Framework

Implemented in *pure* PythonMore libraries for request/response processing.

easy and powerful URL routing conventionsession supporteasy and quick for different output typeseasy object-relation-modelcontroller and model's hook

Page 7: An Introduction to GAEO web framework

GAEO's Architecture

.

.

.

action

action

action

dispatcherclient

requestdispatch

response

Page 8: An Introduction to GAEO web framework

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

Page 9: An Introduction to GAEO web 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 10: An Introduction to GAEO web framework

GAEO 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.BaseControllerImplement the actionclass FooController(BaseController): def bar(self): """ TODO: do things for /foo/bar request """ pass

Page 11: An Introduction to GAEO web framework

GAEO Action Controller (cont.)

Use render method to output different response data. (helps set the Content-Type header)Use redirect method to redirect to another action (or URL)Hook action in before_action and after_action functionMobile device detection. (_is_mobile, _is_iphone, _is_android) Session object.

Page 12: An Introduction to GAEO web framework

GAEO Action Controller (cont.)Sample controller:

from gaeo.controller import BaseController

class FooController(BaseController): def bar(self): name = self.params.get('name', 'anonymous') self.render(html='<h1>Hello, %s' % name)

def update(self): if self._request_method == 'post': // update some model self.redirect('/foo/edit') else: self.render(text="Invalid Request")

Page 13: An Introduction to GAEO web framework

GAEO Model

Extends GAE's Model class.Add one-to-many and many-to-many helperUpdate properties within single method -- update_attributesAdd before_put and after_put hook.

Page 14: An Introduction to GAEO web framework

GAEO Model (cont.)

model sample:

from gaeo.model import BaseModel

class User(BaseModel): name = db.StringProperty() email = db.EmailProperty() created = db.DateTimeProperty(auto_now_add=True)

def before_put(self): // TODO: check property values if failed: return False

Page 15: An Introduction to GAEO web framework

How to Use GAEO

Page 16: An Introduction to GAEO web framework

Installation

Download the release archive, and unpack it.Install it through easy_installSetup the $PATH for using GAEO's utilities.

Page 17: An Introduction to GAEO web framework

GAEO Utilities

gaeo.py - Create a GAEO project.gaeogen.py - Generate a GAEO a controller, model, or plugin.

Page 18: An Introduction to GAEO web framework

Live Demo

Page 19: An Introduction to GAEO web framework

GAEO's Roadmap

XML-RPC supportCachingi18n supportRESTfulExtend the Template engineCMS...

Page 20: An Introduction to GAEO web framework

GAEO Resources

Project home:http://code.google.com/p/google-app-engine-oil/Document site:http://doc.gaeo.org/, http://doc-zhtw.gaeo.org/, http://doc-fr.gaeo.org/, http://doc-ja.gaeo.org/Groups:http://groups.google.com/group/google-app-engine-oilIRC:#gaeo on irc.freenode.net

Page 21: An Introduction to GAEO web framework

Q & A

感謝您的收聽 Thanks for you attendance

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