GAE 命令纪要

阅读更多

基础:

 

dev_appserver.py,开发网络服务器
appcfg.py,用于将您的应用程序上传到 App Engine

 

app.yaml

 

一个 webapp 应用程序包含三部分:

一个或多个 RequestHandler 类,用于处理请求和构建响应

一个 WSGIApplication 实例,按照网址将收到的请求发送给处理程序

一个主要例行程序,用于使用 CGI 适配器运行 WSGIApplication

 

import cgi
import os

from google.appengine.ext import db

from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app

 

class Greeting(db.Model):

 

class MainPage(webapp.RequestHandler):
  def get(self):

 

class Guestbook(webapp.RequestHandler):
  def post(self):

 

application = webapp.WSGIApplication(
                                     [('/', MainPage),
                                      ('/sign', Guestbook)],
                                     debug=True)

 

def main():
  run_wsgi_app(application)

 

if __name__ == "__main__":
  main()

 

 

进阶:
import urllib

def get(self, user):

unescaped_user = urllib.unquote(user)

greeting_user_object = users.User(unescaped_user)

 

('/edituser/([^/]+)', EditUserProfileHandler)

 

greetings_query = Greeting.all().order('date')
greetings = greetings_query.fetch(1000)

 

class BaseRequestHandler(webapp.RequestHandler):

class MainRequestHandler(BaseRequestHandler):

class ChatsRequestHandler(BaseRequestHandler):

 

directory = os.path.dirname(__file__)

path = os.path.join(directory, 'templates', template_name)

self.response.out.write(template.render(path, values, debug=_DEBUG))

 

next:

{% extends "base.html" %}

{% block logo %}

{% endblock %}

 

phrase = singular if count == 1 else plural

 

import game_ajax
import lobby_ajax
import gamemodel

 

players = lobby.lobby_list(50)

return map(lambda obj:obj.player.nickname(), players)

 

active_games = gamemodel.public_game_list()

active_games = filter(lambda gameObj: gameObj.player1 != user and gameObj.player2 != user, active_games)

 

{% include "header.html" %}

 

PIL

http://www.pythonware.com/products/pil/

 

ElementTree

http://effbot.org/zone/element-index.htm

你可能感兴趣的:(GAE,EXT,Google,Ajax,OS)