2011-02-05 23 views
0

我特林在GAE使用Django 1.1,但是當我在這個腳本取消註釋Django的版本在GAE

use_library('django', '1.1')

import os 

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 
from google.appengine.dist import use_library 
#use_library('django', '1.1') 


# Google App Engine imports. 
from google.appengine.ext.webapp import util 

# Force Django to reload its settings. 
from django.conf import settings 

settings._target = None 

import django.core.handlers.wsgi 
import django.core.signals 
import django.db 
import django.dispatch.dispatcher 

# Unregister the rollback event handler. 
django.dispatch.dispatcher.disconnect(
    django.db._rollback_on_exception, 
    django.core.signals.got_request_exception) 

def main(): 
    # Create a Django application for WSGI. 
    application = django.core.handlers.wsgi.WSGIHandler() 

    # Run the WSGI CGI handler with that application. 
    util.run_wsgi_app(application) 

if __name__ == "__main__": 
    main() 

我收到

AttributeError: 'module' object has no attribute 'disconnect'

是什麼繼續?

回答

1

http://justinlilly.com/blog/2009/feb/06/django-app-engine-doc-fix/

對於那些在版本在谷歌 應用程序引擎設置的Django後 信號重構,下面的解決方法是需要通過 谷歌提供的代碼 。

# Log errors. 
django.dispatch.dispatcher.connect(
    log_exception, django.core.signals.got_request_exception) 

# Unregister the rollback event handler. 
django.dispatch.dispatcher.disconnect(
    django.db._rollback_on_exception, 
    django.core.signals.got_request_exception) 

變爲:

# Log errors. 
django.dispatch.Signal.connect(
    django.core.signals.got_request_exception, log_exception) 

# Unregister the rollback event handler. 
django.dispatch.Signal.disconnect(
    django.core.signals.got_request_exception, 
    django.db._rollback_on_exception)