Mi Primera Aplicacion en Google App Engine - Presentation Transcript
Mi Primera Aplicacion usando
Google App Engine
Adrian Catalan
Y que es eso del GAE?
Google App Engine es una plataforma de desarrollo
Python & Java
Cloud Computing
Todo como un servicio
I have not heard two people say the same thing about it [cloud]. There
are multiple definitions out there of “the cloud”
Andy Isherwood, HP’s Vice President of European Software Sales
Google App Engine
Tenemos por seguro que hace una cosa bien: correr
aplicaciones web
Y ademas...
Simple
Escalable
Seguro
Balanceo de carga
App Engine Architecture
req/resp
stateless APIs R/O FS
urlfech Python stdlib
VM
mail process
app
images
stateful datastore
APIs memcache
5
Por que voy a dejar de usar
LAMP?
Pareciera ser EL estandar
...pero
Configuracion
Tuning
Problemas con el Hardware
Updates
Y mas
Datastore
Las Entidades tienen Kind, Key, y Propiedades
Entity ~~ Record ~~ Python dict ~~ Python class
instance
Key ~~ structured foreign key; includes Kind
Kind ~~ Table ~~ Python class
Property ~~ Column or Field; has a type
Desventajas
Ambiente muy controlado
Solo Python y Java por el momento
Facil de usar
...pero limitado (gratis)
Si los frameworks estan atados a bd relacionales, de
que forma pasaran a ser parte de GAE?
Cuando usar GAE
Queremos tenerlo funcionando ASAP
Empezando un proyecto nuevo
Conocemos Python
Las limitaciones no son un problema para nosotros
No estamos en un proyecto muy grande con cosas
dificiles de implementar
Google App Engine
Hacia donde vamos?
Google App Engine
Y ahora...vamos al demo
Como empezamos?
Descargamos el SDK (duh!)
dev_appserver.py
appcfg.py
Hola, mundo...desde la nube!
print 'ContentType: text/plain'
print ' '
print 'Hello, world!'
Y la configuracion?
(app.yaml)
application: helloworld
version: 1
runtime: python
api_version: 1
handlers:
url: /.*
script: helloworld.py
Empezando a usar webapp
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import
run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['ContentType'] =
'text/plain'
self.response.out.write('Hello, webapp World!')
Empezando a usar webapp
application = webapp.WSGIApplication(
[('/', MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Usando el servicio de
usuarios
users.get_current_user()
create_login_url(dest_url)
get_current_user()
ElModelo
class BlogEntry(db.Model):
author = db.UserProperty()
title = db.StringProperty()
content = db.StringProperty(multiline=True)
date=db.DateTimeProperty(auto_now_add=True)
El resto de ElModelo
class BlogComment (db.Model):
author = db.UserProperty()
content = db.StringProperty(multiline=True)
date=db.DateTimeProperty(auto_now_add=True)
entry =
db.ReferenceProperty(BlogEntry,collection_name
='cm')
Agregando al Datastore
class Entry (webapp.RequestHandler):
def post(self):
en = BlogEntry()
en.author = users.get_current_user()
en.content = self.request.get('content')
en.title = self.request.get('title')
en.put()
self.redirect('/')
0 comments
Post a comment