I'm having an issue with printing out greetings.
Here is my greeting program:
===================
import datetime
from couchdbkit import *
class Greeting(Document):
author = StringProperty()
content = StringProperty()
date = DateTimeProperty()
# server object
server = Server()
# create database
db = server.get_or_create_db("greeting")
# associate Greeting to the db
Greeting.set_db(db)
# create a new greet
greet = Greeting(
author="Benoit",
content="Welcome to couchdbkit world",
date=datetime.datetime.utcnow()
)
# save it
greet.save()
greet.author = "Jacob Fenwick"
greet.save()
greet.homepage = "
http://www.jacobfenwick.com"
greet.save()
push('_design/greeting', db)
greets = Greeting.view('greeting/all')
print list(greets)
===============
Here's map.js:
$ cat _design/greeting/views/all/map.js
function(doc) {
if (doc.doc_type == “Greeting”)
emit(doc._id, doc);
}
=================
And here's the error I get when I run the greeting program:
$ python create.pyTraceback (most recent call last):
File "create.py", line 38, in <module>
print list(greets)
File "/Library/Python/2.6/site-packages/couchdbkit-0.5.4-py2.6.egg/couchdbkit/client.py", line 842, in iterator
self._fetch_if_needed()
File "/Library/Python/2.6/site-packages/couchdbkit-0.5.4-py2.6.egg/couchdbkit/client.py", line 921, in _fetch_if_needed
self.fetch()
File "/Library/Python/2.6/site-packages/couchdbkit-0.5.4-py2.6.egg/couchdbkit/client.py", line 903, in fetch
self._result_cache = self.view._exec(**self.params).json_body
File "/Library/Python/2.6/site-packages/couchdbkit-0.5.4-py2.6.egg/couchdbkit/client.py", line 991, in _exec
return self._db.res.get(self.view_path, **params)
File "build/bdist.macosx-10.6-universal/egg/restkit/resource.py", line 113, in get
File "/Library/Python/2.6/site-packages/couchdbkit-0.5.4-py2.6.egg/couchdbkit/resource.py", line 108, in request
payload=payload, headers=headers, **params)
File "build/bdist.macosx-10.6-universal/egg/restkit/resource.py", line 207, in request
restkit.errors.RequestFailed: {"error":"compilation_error","reason":"Expression does not eval to a function. ((new String(\"function(doc) { \\n if (doc.doc_type == \\u201CGreeting\\u201D) \\n emit(doc._id, doc); \\n}\")))"}
=================
I've noticed there's a 404 error during the call when it pushes the view to couchdb:
[info] [<0.585.0>] 127.0.0.1 - - 'HEAD' /greeting/ 200
[info] [<0.585.0>] 127.0.0.1 - - 'GET' /greeting/_design/greeting 404
[info] [<0.585.0>] 127.0.0.1 - - 'PUT' /greeting/_design/greeting 201
Any insight into what I can do to solve this problem?
I'm running on OS X in case that makes a difference.
Jacob