【问题标题】:Path to django on google app engine谷歌应用引擎上的 django 路径
【发布时间】:2010-12-20 13:52:42
【问题描述】:

我完全不明白这个错误。我使用 django-nonrel,通过 manage.py 将其上传到我的应用程序。 有时我有这个:

<type 'exceptions.AttributeError'>: 'Settings' object has no attribute 'DATABASE_ROUTERS'
Traceback (most recent call last):
File "/base/data/home/apps/appid/3.347077242893060339/execute.py", line 2, in <module>
  from djapp import queue_controller
File "/base/data/home/apps/appid/3.347077242893060339/djapp/queue_controller.py", line 5, in <module>
  from djapp.models import Operation
File "/base/data/home/apps/appid/3.347077242893060339/djapp/models.py", line 3, in <module>
  from django.db import models
File "/base/data/home/apps/appid/3.347077242893060339/django/db/__init__.py", line 66, in <module>
  router = ConnectionRouter(settings.DATABASE_ROUTERS)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/conf/__init__.py", line 32, in __getattr__
  return getattr(self._target, name)

<type 'exceptions.ImportError'>: No module named files.uploadhandler  
Traceback (most recent call last):
File "/base/data/home/apps/appid/3.347067228745038183/djangoappengine/main/main.py", line 28, in <module>
  from django.core.handlers.wsgi import WSGIHandler
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/core/handlers/wsgi.py", line 1, in <module>
  from django.core.handlers.base import BaseHandler
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/core/handlers/base.py", line 3, in <module>
  from django import http
File "/base/data/home/apps/appid/3.347067228745038183/django/http/__init__.py", line 28, in <module>
  from django.http.multipartparser import MultiPartParser
File "/base/data/home/apps/appid/3.347067228745038183/django/http/multipartparser.py", line 14, in <module>
  from django.core.files.uploadhandler import StopUpload, SkipFile, StopFutureHandlers

路径有什么问题?为什么会这样?起初路径是“/base/data/home/apps/app-id/3.347046818251769742/django/”,然后是“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/”。
以及如何避免这个错误?

我检查了 sys.path,多次上传新的 django,删除了所有不必要的文件,我迷路了 :(

sys.path = ['/base/data/home/apps/appid/3.347077364008022180', 
'/base/data/home/apps/appid/3.347077364008022180/djangoappengine/lib', 
'/base/python_runtime/python_dist/lib/python25.zip', 
'/base/python_runtime/python_dist/lib/python2.5/', 
'/base/python_runtime/python_dist/lib/python2.5/plat-linux2', 
'/base/python_runtime/python_dist/lib/python2.5/lib-tk',
'/base/python_runtime/python_dist/lib/python2.5/lib-dynload',
'/base/python_runtime/python_lib/versions/1',
'/base/data/home/apps/appid/3.347077364008022180/']

【问题讨论】:

  • 您在使用 appstats 吗?当一个实例在该实例上使用 nonrel 之前加载默认 Django 时,似乎会发生这种事情。
  • 我上传了“appengine 控制台”应用程序,该应用程序也加载了 django,然后将其删除。现在我的应用程序中只有 django-nonrel 和 wave 机器人 api。实例如何加载默认的 Django?

标签: google-app-engine django-nonrel


【解决方案1】:

我猜db/__init__.py 做了类似from django.conf import Settings 的事情,并且无论出于何种原因,它有时会被赋予系统版本的 Django 而不是你自己的。

您可以尝试将其更改为使用相对导入,例如from ..conf import Settings,这应该意味着它使用与自身相同的包中的版本。这适用于 Appengine 使用的 Python 2.5。

【讨论】:

  • 这不起作用。而且我知道有时它会被赋予系统版本的 Django .. 但是为什么呢? Django 不应该导入自己而不是系统的吗?
  • 嗯,要知道 Python 从哪里获取东西并不总是那么容易,尤其是在 appengine 上,您不知道它是如何运行的。可能是在sys.modules 中查找模块,也可能是sys.path 中的文件夹顺序错误。
猜你喜欢
  • 1970-01-01
  • 2016-03-11
  • 1970-01-01
  • 2012-02-21
  • 2012-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-20
相关资源
最近更新 更多