An Introduction to GAEO web framework

Post on 31-Aug-2014

3695 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

The GAEO talk in OSDC.tw 2009

Transcript

An Introduction to GAEO web

framework

ericskOSDC.tw 2009

Agenda

Google App EngineWhy GAEO?How to use GAEORoadmapLive Demo

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

Google App Engine (cont.)

Dashboard

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.

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

GAEO's Architecture

.

.

.

action

action

action

dispatcherclient

requestdispatch

response

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

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

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

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.

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

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.

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

How to Use GAEO

Installation

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

GAEO Utilities

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

Live Demo

GAEO's Roadmap

XML-RPC supportCachingi18n supportRESTfulExtend the Template engineCMS...

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

Q & A

感謝您的收聽 Thanks for you attendance

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

top related