我很难让 couchdbkit 在 Google App Engine 上正常运行。我要么没有正确导入我的库,要么违反了GAE 的 Python Sandbox 规则。任何人都知道在 GAE 上使用 couchdbkit 时是否需要包含 restkit(这就是一些问题的来源)?
这是我的配置:
app.yaml
zapdome.py
couchdbkit/
restkit/
我已经将 zapdome.py 剥离为基础知识(连接到我的 CouchDB 数据库服务器):
#! /usr/bin/env python
import urllib, httplib, datetime
from couchdbkit.schema.base import *
from couchdbkit.schema.properties import *
from couchdbkit.client import Server
USERNAME = ''
PASSWORD = ''
class QuoteEntry(Document):
name = StringProperty()
symbol = StringProperty()
price = StringProperty()
server = Server('https://' + USERNAME + ':' + PASSWORD + '@' + USERNAME + '.cloudant.com/')
这些是我正在记录的错误:
E 2011-05-05 20:39:31.309
Traceback (most recent call last):
E 2011-05-05 20:39:31.309
File "/base/data/home/apps/zapdome/1.350215157753999092/restkit/__init__.py", line 12, in <module>
E 2011-05-05 20:39:31.309
from .client import Client, MAX_FOLLOW_REDIRECTS
E 2011-05-05 20:39:31.309
File "/base/data/home/apps/zapdome/1.350215157753999092/restkit/client.py", line 21, in <module>
E 2011-05-05 20:39:31.309
from httplib import FakeSocket
E 2011-05-05 20:39:31.309
ImportError: cannot import name FakeSocket
E 2011-05-05 20:39:31.309
Traceback (most recent call last):
E 2011-05-05 20:39:31.309
File "/base/data/home/apps/zapdome/1.350215157753999092/couchdbkit/__init__.py", line 10, in <module>
E 2011-05-05 20:39:31.310
from .resource import RequestFailed, CouchdbResource
E 2011-05-05 20:39:31.310
File "/base/data/home/apps/zapdome/1.350215157753999092/couchdbkit/resource.py", line 25, in <module>
E 2011-05-05 20:39:31.310
from restkit import Resource, ClientResponse
E 2011-05-05 20:39:31.310
ImportError: cannot import name Resource
E 2011-05-05 20:39:31.310
<type 'exceptions.SyntaxError'>: 'import *' not allowed with 'from .' (__init__.py, line 159)
Traceback (most recent call last):
File "/base/data/home/apps/zapdome/1.350215157753999092/zapdome.py", line 4, in <module>
from couchdbkit.schema.base import *
由于它在 httplib.FakeSocket 和 restkit.Resource 上令人窒息,我开始认为我超出了 GAE 允许的范围。有人有什么想法吗?谢谢。