Python reports a KeyError when I try to access some view results with reduce=False. I hope someone can help me identify the problem. Any assistance would be appreciated. Below are some details. Please let me know what other information would help. Thanks.
The view statement is:
view_result = DefaultPeak.view('default_peak/{0}'.format(view), reduce=False, limit=1)
view_result.first() produces the following Traceback:
Exception Location: /usr/local/lib/python2.7/dist-packages/couchdbkit/schema/util.py in wrap, line 29
Django Version: 1.5.dev17942
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs) File "/home/vincent/Django/mysite/default_peak/views.py" in home
165. view_result.first() File "/usr/local/lib/python2.7/dist-packages/couchdbkit/client.py" in first
930. return list(self)[0] File "/usr/local/lib/python2.7/dist-packages/couchdbkit/client.py" in iterator
920. yield wrapper(row) File "/usr/local/lib/python2.7/dist-packages/couchdbkit/client.py" in row_wrapper
901. return schema(data) File "/usr/local/lib/python2.7/dist-packages/couchdbkit/schema/util.py" in wrap
29. cls = classes[doc_type]
Exception Type: KeyError at /
Variable | Value |
---|
doctype_attr | 'doc_type' |
doc_type | None |
classes | {'DefaultPeak': <class 'default_peak.models.DefaultPeak'>} |
The exception occurs because doc_type is None and classes[None] does not exist.
Couchdb produces basically the same information with reduce=True and reduce=False&limit=1
{"rows":[
{"key":null,"value":{"OS":"linux","StartTime":"2012-06-12 10:27:56.119293",...}}
]}
reduce=False&limit=1:
{"total_rows":74,"offset":0,"rows":[
{"id":"00a54b28-b454-11e1-87e9-00259055f3e6","key":"prf-lin-15","value":{"OS":"linux","StartTime":"2012-06-12 00:01:07.897811",...}}
]}
I have been able to use reduce=False successfully with other views such as:
view_result = DefaultPeak.view( 'default_peak/variance', reduce=False, startkey=[ serial, metric ], endkey=[ serial, metric, {}] )