3. 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 infrastructure
Cron service (NEW )
Both Python and Java (NEW ) are
supported
5. Why GAEO?
I need a web framework.
webapp is too simple; django is too complicated.
GAEO: Google App Engine Oil
Convension over configuration.
More easily development on GAE to Rails/Zend
Framework developers.
6. What is GAEO?
Model-Template-Controller -based web framework.
based on webapp
inspired from Rails/Zend Framework
Implemented in *pure* Python
More libraries for request/response processing.
easy and powerful URL routing convention
session support
easy and quick for different output types
easy object-relation-model
controller and model's hook
10. GAEO 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
11. 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 function
Mobile device detection. (_is_mobile, _is_iphone,
_is_android)
Session object.
12. 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=quot;Invalid Requestquot;)
13. GAEO Model
Extends GAE's Model class.
Add one-to-many and many-to-many helper
Update properties within single method -- update_attributes
Add before_put and after_put hook.
14. 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