我很難讓couchdbkit在Google App Engine上正常運行。我要麼沒有正確導入我的圖書館,要麼我已經與GAE's Python Sandbox rules發生衝突。任何人都知道在GAE上使用couchdbkit時是否需要包含restkit(這是一些問題的來源)?在Google App Engine上使用couchdbkit(第三方庫)
這裏是我的配置:
的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允許的範圍。任何人有任何想法?謝謝。
@德魯 - 西爾斯,良好的出發點,但更改爲: '進口urllib的,httplib的,日期時間 從couchdbkit.schema.base進口文件 從couchdbkit.schema.properties導入StringProperty 從couchdbkit.client導入服務器' 會產生相同的錯誤日誌。我注意到在couchdbkit/schema/__ init__.py這裏有:.properties import * 'from .base import * from .properties_proxy import *' – Ryan 2011-05-06 13:20:05