2010-12-20 98 views
0

我完全不明白這個錯誤。我使用django-nonrel,通過manage.py將其上傳到我的應用程序。而有時我有這樣的:谷歌應用引擎Django的路徑

<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/'] 
+0

您使用的是appstats嗎?當nonrel在該實例上使用之前,實例加載默認的Django時,似乎會發生這種事情。 – geoffspear 2010-12-20 16:55:14

+0

我上傳了「appengine console」應用程序,它也加載了django,然後將其刪除。現在我的應用程序中只有django-nonrel和wave robot api。一個實例如何加載默認的Django? – shmakova 2010-12-21 21:05:10

回答

0

我想這db/__init__.py確實像from django.conf import Settings,以任何理由,它有時給你係統的Django版本而不是你自己的版本

你可以嘗試改變它以使用相對導入,如from ..conf import Settings,這應該意味着它使用與它自己相同的包中的版本。這是Appengine使用的。

+0

這沒有奏效。我明白,有時它被賦予系統的Django版本。但是,爲什麼? Django不應該導入自己而不是系統? – shmakova 2010-12-21 21:18:13

+0

嗯,要知道Python從哪裏得到什麼東西並不總是很容易,尤其是在appengine上,在那裏你不知道它究竟是如何運行的。它可能在'sys.modules'中查找模塊,或者可能是'sys.path'中的文件夾順序錯誤。 – 2010-12-21 21:30:07