trouble when setting reduce=False in view

80 views
Skip to first unread message

Vincent

unread,
Jun 25, 2012, 6:33:47 PM6/25/12
to couch...@googlegroups.com
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.  

Vincent

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

Environment:

Request Method: GET
Request URL: http://IP:8000/

Django Version: 1.5.dev17942
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'couchdbkit.ext.django',
 'django.contrib.humanize',
 'polls',
 'testdata',
 'default_peak')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
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 /
Exception Value: None

VariableValue
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.

The class DefaultPeak is defined with no static properties:
class DefaultPeak(Document):
    def __unicode__(self):
        return None
    class Meta:
        app_label = "default_peak"

Couchdb produces basically the same information with reduce=True and reduce=False&limit=1

reduce=True:
{"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, {}] )

Vincent

unread,
Jun 26, 2012, 6:12:46 PM6/26/12
to couch...@googlegroups.com
In further testing this exception occurs when my Couchdb map function emits a value that is a basic Javascript object/dictionary rather than a Javascript array. When the emit statement takes the form emit( key, {a:1,b:2,c:3} ) the exception occurs but it does not occur with an emit statement of the form emit( key, [1,2,3] ). 

I tried the wrap_doc=False option but this did not resolve the issue. The wrap_doc option appears to be passed along to Couchdb (where it has no meaning) and is not caught by Couchdbkit. The statement

view_result = DefaultPeak.view('default_peak/testview', wrap_doc=False, reduce=False) produces in the Couchdb log:

GET /perf_test/_design/default_peak/_view/testview?reduce=false&wrap_doc=false

I added a static property workAround = IntegerProperty(required=False) to my DefaultPeak(Document) so that it is no longer empty but the problem still occurs.

Benoit Chesneau

unread,
Jun 27, 2012, 2:00:15 AM6/27/12
to couch...@googlegroups.com
Do you have any errors on couchdb level? What is your couchdbkit version?

- benoit
> --
> You received this message because you are subscribed to the Google Groups
> "couchdbkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/couchdbkit/-/fsMAVD7Evh0J.
>
> To post to this group, send email to couch...@googlegroups.com.
> To unsubscribe from this group, send email to
> couchdbkit+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/couchdbkit?hl=en.

Benoit Chesneau

unread,
Jun 27, 2012, 5:02:31 AM6/27/12
to couch...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "couchdbkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/couchdbkit/-/fsMAVD7Evh0J.
To post to this group, send email to couch...@googlegroups.com.
To unsubscribe from this group, send email to couchdbkit+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchdbkit?hl=en.


Can you open a ticket on github? I will do some tests today.

- benoît

Vincent

unread,
Jun 27, 2012, 10:55:04 AM6/27/12
to couch...@googlegroups.com
I am using version 0.6.2 of Couchdbkit. Couchdb reports no errors. I will open a ticket shortly. Thanks.
Reply all
Reply to author
Forward
0 new messages