English 中文(简体)
在亚洲开发银行的支持下,找到一个关键错误
原标题:Getting a KeyError in DB backend of django-digest

I have just started to integrate django_digest into my app. As a start I have added the @httpdigest decorator to one of my views. If I try to connect to it I get a KeyError exception thrown in django_digest/backend/db.py . Depending on which db I configure I get a different KeyError in a different location. I am using Django 1.2.1, with MySql (also tested with sqlite). I am using the default values for all the settings options.

我可以看到,我遵守了所有指示,但每天都在为此而努力。 我使用的是集延戈-最穷困者和最穷困者。 任何指示都将受到高度赞赏。

below和 my泥的追踪:

注:

Traceback (most recent call last):
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 248, in __call__
    signals.request_finished.send(sender=self.__class__)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/dispatch/dispatcher.py", line 162, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django_digest-1.8-py2.5.egg/django_digest/backend/db.py", line 16, in close_connection
    _connection.close()
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/db/backends/sqlite3/base.py", line 186, in close
    if self.settings_dict[ NAME ] != ":memory:":
KeyError:  NAME 

Traceback (most recent call last):
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/handlers/base.py", line 142, in get_response
    return self.handle_uncaught_exception(request, resolver, exc_info)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/handlers/base.py", line 166, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/core/handlers/base.py", line 80, in get_response
    response = middleware_method(request)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django_digest-1.8-py2.5.egg/django_digest/middleware.py", line 13, in process_request
    if (not self._authenticator.authenticate(request) and
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django_digest-1.8-py2.5.egg/django_digest/__init__.py", line 86, in authenticate
    partial_digest = self._account_storage.get_partial_digest(digest_response.username)
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django_digest-1.8-py2.5.egg/django_digest/backend/db.py", line 97, in get_partial_digest
    cursor = get_connection().cursor()
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/db/backends/__init__.py", line 75, in cursor
    cursor = self._cursor()
  File "/home/robm/projects/gcs/server/gcs2.5/lib/python2.5/site-packages/django/db/backends/mysql/base.py", line 281, in _cursor
    if settings_dict[ USER ]:
KeyError:  USER 

<>Update-这似乎与Django 1.2和多数据库背对。 修改数据集,摘自:

_connection = backend.DatabaseWrapper({                                          
         DATABASE_HOST : settings.DATABASE_HOST,                                 
         DATABASE_NAME : settings.DATABASE_NAME,                                 
         DATABASE_OPTIONS : settings.DATABASE_OPTIONS,                           
         DATABASE_PASSWORD : settings.DATABASE_PASSWORD,                         
         DATABASE_PORT : settings.DATABASE_PORT,                                 
         DATABASE_USER : settings.DATABASE_USER,                                 
         TIME_ZONE : settings.TIME_ZONE,                                         
        })                                                                       

内容提要

_connection = backend.DatabaseWrapper({
                 HOST : settings.DATABASE_HOST,
                 NAME : settings.DATABASE_NAME,
                 OPTIONS : settings.DATABASE_OPTIONS,
                 PASSWORD : settings.DATABASE_PASSWORD,
                 PORT : settings.DATABASE_PORT,
                 USER : settings.DATABASE_USER,
                 TIME_ZONE : settings.TIME_ZONE,
                })

应加以确定。

现在,我转而使用《吉大港山区行动计划》的网页,但希望下周我有机会做一次小事。

问题回答

仅仅这样,问题如所回答,就增加了我作为答案在上文评论中增加的解决办法(这是正确的事情吗?)

看来这在Django 1.2和多数据库背后是具体的。 修改数据集,摘自:

_connection = backend.DatabaseWrapper({                                          
     DATABASE_HOST : settings.DATABASE_HOST,                                 
     DATABASE_NAME : settings.DATABASE_NAME,                                 
     DATABASE_OPTIONS : settings.DATABASE_OPTIONS,                           
     DATABASE_PASSWORD : settings.DATABASE_PASSWORD,                         
     DATABASE_PORT : settings.DATABASE_PORT,                                 
     DATABASE_USER : settings.DATABASE_USER,                                 
     TIME_ZONE : settings.TIME_ZONE,                                         
    })         

内容提要

_connection = backend.DatabaseWrapper({
             HOST : settings.DATABASE_HOST,
             NAME : settings.DATABASE_NAME,
             OPTIONS : settings.DATABASE_OPTIONS,
             PASSWORD : settings.DATABASE_PASSWORD,
             PORT : settings.DATABASE_PORT,
             USER : settings.DATABASE_USER,
             TIME_ZONE : settings.TIME_ZONE,
            })

应加以确定。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签