在 App Engine/Django 中导入中间件类时遇到问题
尝试让 facebook connect 在应用程序引擎上工作,因此我遵循以下说明:
http://www.slideshare.net/mrtrosen/lab305-django-facebook-connect-integration-example
其中一个步骤要求我添加到我的 middleware_classes 中,所以我已经将以下内容添加到settings.py(从上面演示文稿中的幻灯片18复制):
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'facebook.djangofb.FacebookMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'facebookconnect.middleware.FacebookConnectMiddleware',
)
但是,当我在本地查看我的应用程序(在将其添加到settings.py之前该应用程序正在运行)时,我收到以下错误:
配置不正确:导入时出错 中间件 facebook.djangob:“不 名为 facebook.djangob 的模块”
但是,当我进入终端时,我能够运行 python,当我输入“import facebook.djangofb”时,我没有收到任何错误。
仅供参考,facebook 包位于 /Library/Python/ 中2.6/site-packages。
关于为什么会发生这种情况,我已经坚持了一段时间了,所以我们将不胜感激
!
Trying to get facebook connect to work on app engine, and so I'm following these instructions:
http://www.slideshare.net/mrtrosen/lab305-django-facebook-connect-integration-example
One of the steps requires me to add to my middleware_classes, and so I've added the following to settings.py (copied from slide 18 in the presentation above):
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'facebook.djangofb.FacebookMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'facebookconnect.middleware.FacebookConnectMiddleware',
)
However, when I view my app locally (which was working before adding this to settings.py), I get the following error:
ImproperlyConfigured: Error importing
middleware facebook.djangofb: "No
module named facebook.djangofb"
However, when I go to the terminal, I am able to run python and when I type "import facebook.djangofb" I do not get any error.
FYI, the facebook package is in /Library/Python/2.6/site-packages.
Any ideas as to why this might be happening? I've been stuck on this for a while so any help would be greatly appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我相信 Google App Engine 使用 python 2.5 运行时,因此您可以按照上面的建议将 facebook 目录移动到项目中,或者如果您也安装了 python 2.5,则将其移动到 2.5 站点包中。
Google App Engine uses python 2.5 runtime I believe, thus you will have either move the facebook directory into the project as suggested above or move it over to the 2.5 site-packages if you have python 2.5 installed as well.
所有模块必须位于应用程序的文件夹层次结构下。请务必将所需的路径添加到应用请求处理程序中的
sys.path
中。sys.path
应更新为以下内容:其中
folderX
包含在app
文件夹下。这种“路径调整”应该在应用程序中的每个“请求入口点脚本”中完成。All modules must reside under your app's folder hierarchy. Be sure to also add the required paths to
sys.path
in your app request handlers.The
sys.path
should be updated to something along the lines of:where
folderX
is contained under theapp
folder. This "path adjustment" should be done in each "request entry point script" in the application.