English 中文(简体)
构建 Google 应用程序引擎
原标题:buildout google app engine

我需要构建 Google 应用程序引擎。 我写了配置文件构建。 cfg:

[buildout]
parts =
    gae_sdk
    gae_tools
    app_lib

unzip = true
relative-paths = true
download-cache = etc/downloads
develop-eggs-directory = etc/develop-eggs
parts-directory = etc/parts


[gae_sdk]
recipe = appfy.recipe.gae:sdk
url = http://googleappengine.googlecode.com/files/google_appengine_1.4.3.zip
destination = ${buildout:parts-directory}
hash-name = false
clear-destination = true


[gae_tools]
recipe = appfy.recipe.gae:tools
sdk-directory = ${gae_sdk:destination}/google_appengine

[app_lib]
recipe = appfy.recipe.gae:app_lib
lib-directory = src/distlib
use-zipimport = false


eggs =
    webapp2

运行命令 python & lt; (curl < a href=" http://python- dispiritte. org/bootsstrap. py" rel=“ no follow” > http://python- dispretarte. org/bootsapt. py ) - 分布和. /bin/buildingout GAE 并不想工作。 服务器正在工作, 但 GAE 网站上最简单的 Hello World 显示一个错误导入错误的错误地址: 没有名为 Webapp2 的模块。 在我脚本、 文件及文件夹结构为: progect/buildingout. cfg progect/src/ hello_world. py, ap.yaml

file app.yaml:
application: hello_world
version: 1
runtime: python
api_version: 1
threadsafe: true

handlers:
- url: /.*
script:hello_world.app

builtins:
- deferred: on

file hello_world.py:
import webapp2

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers = ‘text/plain’
self.response.out.write( Hello, webapp World! )

app = webapp2.WSGIApplication(,
debug=True)
help me, please.
最佳回答

Webap2 包含在最近的 SDKs (google_appengine/lib/webapp2) 中。 如果您使用更新的 SDK 或不导入 Webap2, 它应该为您工作 。

如果你对一个稍微不同的建筑计划感兴趣, 我包括了一个。

我一直在用rod.recipe.appengine来建造, 并且非常满意。 它甚至允许您修补应用程序引擎SDK。 如果您需要修补 PyCrypto < a href=", http://code.google.com/ p/googleapengine/issues/ detail?id=4612" rel="nofol" >imports 等。

我根据bobo < a href=" http://code.google.com/p/typhoonae/wiki/AppEngineBuildout" rel=“nofolt” >example 和其他一些来源做了我的配置。下面的例子可以让您从 dist.plone.org 获得像 PIL 这样的依赖性。 它为加密方便的窗体处理和 gdata 提取 wtforms, 并将其放入包中。zip 可以在进口前添加到 sys.path 的包件中。 例如, 在 lippedpackages 看起来像 lippedpackages. py

import sys
if  packages.zip  not in sys.path:
    sys.path.insert(0,  packages.zip )

请注意,设置.py 和 app.yaml 是由模板和变量生成的,例如 appspotname appspotversversion

构建基于一个运行中的构建, 但这个精确的示例尚未测试, 也缺少一些模板。 如果您查看 Pypi 上的不同配方, 您可以读取选项和语法 。

如果您使用模板, 您可能需要两次运行构建文件, 以便首先从模板中生成文件( 在我设置的 Src 目录中), 然后创建与部件目录( SDK 运行的路径) 的符号链接 。 如果您不想使用模板, 从构建中移除并设置 。 使用 eggs 而不是 evilenv 使您能够将库转换为配置, 而不是有不同的虚拟元件 。 虽然这不是一个大问题, 因为图书馆版本很少改变 。 如果您遇到与鸡蛋有关的问题, 也值得注意的是 SDK 导入的魔法已经意识到了网站包件, 并且在某种程度上是虚拟元件, 但不包括鸡蛋, 所以有些库可能还是要安装在虚拟元箱中 。

[buildout]
appspotname = progect
appspotversion = dev

versions = versions
develop =
    src/progect
parts =
    progect
    progectconfig
    progectsettings
    nosetests
    noseconfig
    zipsymlink

unzip = true

find-links =
    http://dist.plone.org/thirdparty/

[progect]
recipe = rod.recipe.appengine
url = http://googleappengine.googlecode.com/files/google_appengine_1.6.6.zip
server-script = dev_appserver
packages =
    wtforms
    gdata
src = ${buildout:directory}/src/progect
exclude = tests
zip-packages = True
use_setuptools_pkg_resources = True
# We have a patch overriding imports to enable buildout and eggs
#patch = ${buildout:directory}/google_appserver.patch

[progectconfig]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/app.yaml.in
output = ${progect:src}/app.yaml

[progectsettings]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/settings.py.in
output = ${progect:src}/settings.py

[nosetests]
recipe = zc.recipe.egg
eggs =
    NoseGAE
    WebTest
    progect
    nose

extra-paths =
    ${buildout:directory}/etc
    ${buildout:directory}/parts/google_appengine
    ${buildout:directory}/parts/google_appengine/lib/antlr3
    ${buildout:directory}/parts/google_appengine/lib/django_1_3
    ${buildout:directory}/parts/google_appengine/lib/fancy_urllib
    ${buildout:directory}/parts/google_appengine/lib/ipaddr
    ${buildout:directory}/parts/google_appengine/lib/webob_1_1_1
    ${buildout:directory}/parts/google_appengine/lib/webapp2/
    ${buildout:directory}/parts/google_appengine/lib/yaml/lib
    ${buildout:directory}/parts/google_appengine/lib/simplejson
    ${buildout:directory}/parts/google_appengine/lib/graphy
interpreter = python

[noseconfig]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/setup.cfg.in
output = ${buildout:directory}/setup.cfg

[zipsymlink]
recipe = svetlyak40wt.recipe.symlinks
path = ${progect:src}
files = ${progect:app-directory}/packages.zip

[versions]
Django = 1.3
gdata = 2.0.16
lxml = 2.3
PIL = 1.1.7
PyCrypto = 2.3
setuptools = 0.6c11
webapp2 = 2.3
WebOb = 1.1.1
WTForms = 1.0.1

# Tools and dependencies
svetlyak40wt.recipe.symlinks = 0.2.1

App.yaml 应用程序模板可以看起来像

application: ${buildout:appspotname}
version: ${buildout:appspotversion}
runtime: python27
threadsafe: true
api_version: 1

libraries:
- name: PIL
  version: "${versions:PIL}"
- name: pycrypto
  version: "${versions:PyCrypto}"
- name: django
  version: "${versions:Django}"
- name: lxml
  version: "${versions:lxml}"
- name: setuptools
  version: "${versions:setuptools}"
- name: webapp2
  version: "${versions:webapp2}"
- name: webob
  version: "${versions:WebOb}"

handlers:
- url: /.*
  script:hello_world.app
- url: /_ah/queue/deferred
  script: google.appengine.ext.deferred.application
  login: admin

builtins:
- deferred: on

nose 测试配置模板, 对 src 目录进行测试( 相对于主要替代部件/ 预测) :

[nosetests]
verbosity=1
detailed-errors=1
with-gae=1
gae-application=${progect:src}
gae-lib-root=${buildout:directory}/parts/google_appengine
where=${progect:src}

当我想设置这个设置时, 我会去建立 root 目录和类型

/path/to/appropriate/python bootstrap.py --distribute
bin/buildout -c buildout.cfg

然后我就可以运行 >bin/nosetests >bin/dev_app_server parts/ progect

问题回答

webap2 不包含在 stk 中, 您需要将软件包安装到 python 环境中, 或者将软件包包含在构建中, 如果您在构建中使用沙箱或 Vilentenv 。





相关问题
How to make logging.debug work on Appengine?

I m having a tough time getting the logging on Appengine working. the statement import logging is flagged as an unrecognized import in my PyDev Appengine project. I suspected that this was just an ...

gqlQuery returns object, want list of keys

Is there a way to convert the GqlQuery object to an array of keys, or is there a way to force the query to return an array of keys? For example: items = db.GqlQuery("SELECT __key__ FROM Items") ...

Integrating Google AppEngine with a Thick Client

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end. The problem is that GAE provides only web-based forms for ...

sorl.thumbnail : thumbnail is not a valid tag library?

I am trying to install sorl.thumbnail but am getting the following error message: thumbnail is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module ...

热门标签