Ah yes. That's what I get for editing from my Windows box. I stripped the carriage returns and looks like it's working! Thanks very much for your help.
On Thu, Jun 30, 2011 at 4:38 PM, Kxepal <kxe...@gmail.com> wrote:
Wow. Looks like just SyntaxError, but it shouldn't have to produce double fail. Ok, I'll look why it happened.Problem is that Python < 2.7 doesn't allows Windows/Mac style newlines within compile function (\r\n chars) [1]. That's my fault especially because I'm using Linux on my dev notebook and I even didn't know about such behavior(: Shortest workaround is to replace all \r\n chars to \n in function source code. I'll attach fixed version on this weekends due to I'm currently rewriting test methods from functional to pure unit tests.Thanks for report!(:[1] http://docs.python.org/library/functions.html#compile
On Friday, July 1, 2011 12:29:36 AM UTC+4, John Meehan wrote:Hi,Not sure if I've done something wrong with my list code or if I'm running into an issue with the new view server. The views I'd written worked as expected so I take it that the new view server files were installed OK, but now trying to write a test list against one of those views seems to encounter an issue compiling the list code. This looks like the relevant portion of the view server log. Any thoughts?[2011-06-30 15:17:18,362] [couchdb.server.ddoc] [DEBUG] Processing DDoc command `lists`[2011-06-30 15:17:18,362] [couchdb.server.compiler] [DEBUG] Compiling code to function:def fun(head, req):start({"headers": {"Content-Type": "text/html"}})c = 0for row in get_row():send(str(c) + row['key'][0])c+=1[2011-06-30 15:17:18,363] [couchdb.server.compiler] [ERROR] Failed to compile functiondef fun(head, req):start({"headers": {"Content-Type": "text/html"}})c = 0for row in get_row():send(str(c) + row['key'][0])c+=1Traceback (most recent call last):File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/compiler.py", line 284, in compile_funcbytecode = compile(funstr, '<string>', 'exec')File "<string>", line 1def fun(head, req):^SyntaxError: invalid syntax[2011-06-30 15:17:18,363] [couchdb.server] [ERROR] Error `compilation_error` occurred: invalid syntax (<string>, line 1)Traceback (most recent call last):File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/__init__.py", line 253, in runretval = self.commands[cmd](*args)File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/ddoc.py", line 83, in ddocfunc = compile_func(func, ddoc)File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/compiler.py", line 288, in compile_funcraise Error('compilation_error', err)Error: ('compilation_error', SyntaxError('invalid syntax', ('<string>', 1, 20, 'def fun(head, req):\r\n')))[2011-06-30 15:17:18,363] [couchdb.server.stream] [DEBUG] Data to respond:['error', 'compilation_error', SyntaxError('invalid syntax', ('<string>', 1, 20, 'def fun(head, req):\r\n'))][2011-06-30 15:17:18,363] [couchdb.server] [ERROR] TypeError: SyntaxError('invalid syntax', ('<string>', 1, 20, 'def fun(head, req):\r\n')) is not JSON serializableTraceback (most recent call last):File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/__init__.py", line 255, in runretval = self.error_handler(*sys.exc_info())File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/__init__.py", line 233, in error_handlerreturn self.error_handlers.get(type, default)(type, value, traceback)File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/__init__.py", line 176, in handle_qs_errorstream.respond(retval)File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/server/stream.py", line 43, in respondobj = json.encode(obj)File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/json.py", line 65, in encodereturn _encode(obj)File "/usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb/json.py", line 113, in <lambda>dumps(obj, allow_nan=False, ensure_ascii=False)File "/usr/lib/pymodules/python2.6/simplejson/__init__.py", line 237, in dumps**kw).encode(obj)File "/usr/lib/pymodules/python2.6/simplejson/encoder.py", line 200, in encodechunks = self.iterencode(o, _one_shot=True)File "/usr/lib/pymodules/python2.6/simplejson/encoder.py", line 260, in iterencodereturn _iterencode(o, 0)File "/usr/lib/pymodules/python2.6/simplejson/encoder.py", line 177, in defaultraise TypeError(repr(o) + " is not JSON serializable")TypeError: SyntaxError('invalid syntax', ('<string>', 1, 20, 'def fun(head, req):\r\n')) is not JSON serializable[2011-06-30 15:17:18,380] [couchdb.server.stream] [DEBUG] Data to respond:['error', 'TypeError', "SyntaxError('invalid syntax', ('<string>', 1, 20, 'def fun(head, req):\\r\\n')) is not JSON serializable"]On Wed, Jun 29, 2011 at 2:09 PM, Kxepal <kxe...@gmail.com> wrote:Just extract couchdb folder from archive over couchdb installed package: where should be added server folder and replaced view.py by new one.Next thing you have to do is specify version of CouchDB against that query server will be runned (supported since 0.9 till 1.1.0).This could be done by edition [query_server] config option to made it looks like this (for 1.1.0 version):python=/path/to/couchpy --couchdb-version=1.1.0And it should work(: For more information you may build sphinx docs - there have described all command line options, objects and usage examples.
On Wednesday, June 29, 2011 10:12:53 PM UTC+4, John Meehan wrote:Thanks! My next question, however, is how do I install the updated files?I downloaded query-server.tar.gz from your May 9th post in the issue 146 thread.I'm running Ubuntu 10.04, and installed couchdb-python originally with easy-install. So I have the following in my /usr/local/lib/python2.6/dist-packages/CouchDB-0.8-py2.6.egg/couchdb dir:-rwxr-xr-x 1 root staff 37477 2011-06-01 09:58 client.py-rw-r--r-- 1 root staff 45267 2011-06-01 09:58 client.pyc-rwxr-xr-x 1 root staff 7649 2011-06-01 09:58 design.py-rw-r--r-- 1 root staff 8355 2011-06-01 09:58 design.pyc-rwxr-xr-x 1 root staff 17607 2011-06-01 09:58 http.py-rw-r--r-- 1 root staff 20156 2011-06-01 09:58 http.pyc-rwxr-xr-x 1 root staff 534 2011-06-01 09:58 __init__.py-rw-r--r-- 1 root staff 687 2011-06-01 09:58 __init__.pyc-rwxr-xr-x 1 root staff 4441 2011-06-01 09:58 json.py-rw-r--r-- 1 root staff 5859 2011-06-01 09:58 json.pyc-rwxr-xr-x 1 root staff 22337 2011-06-01 09:58 mapping.py-rw-r--r-- 1 root staff 34371 2011-06-01 09:58 mapping.pyc-rwxr-xr-x 1 root staff 8640 2011-06-01 09:58 multipart.py-rw-r--r-- 1 root staff 9080 2011-06-01 09:58 multipart.pycdrwxr-sr-x 2 root staff 4096 2011-06-01 09:58 testsdrwxr-sr-x 2 root staff 4096 2011-06-01 09:58 tools-rwxr-xr-x 1 root staff 7167 2011-06-01 09:58 view.py-rw-r--r-- 1 root staff 7498 2011-06-01 09:58 view.pyc
(I'm assuming I need to overwrite or add the new files from the archive here.)
On Wed, Jun 29, 2011 at 12:20 PM, Kxepal <kxe...@gmail.com> wrote:
On Wednesday, June 29, 2011 7:58:11 PM UTC+4, John Meehan wrote:Can Lists be written in Python?
What would be the Python equivalent of this example from the CouchDB
wiki (http://wiki.apache.org/couchdb/Formatting_with_Show_and_List)?
function(head, req) {
var row;
start({
"headers": {
"Content-Type": "text/html"
}
});
while(row = getRow()) {
send(row.value);
}
}Hi!Currently this could be done by using new query server from issue 146 (http://code.google.com/p/couchdb-python/issues/detail?id=146)Equivalent would be :def fun(head, req):start({"headers": {"Content-Type": "text/html"}})for row in get_row():send(row["value"])Notice, that get_row function is generator and any dotted notation accessed attributes should be changed to getitem specification due to this is dict object.Also notice, that builtn query server function are respect PEP-8, so there is nothing mixedCased nor CamelCase except exceptions(Forbidden, Error, FatalError).If you would try this query server any feedback would be great(:--,,,^..^,,,--To view this discussion on the web visit https://groups.google.com/d/msg/couchdb-python/-/KQWWZ2-nQo0J.
You received this message because you are subscribed to the Google Groups "CouchDB-Python" group.
To post to this group, send email to couch...@googlegroups.com.
To unsubscribe from this group, send email to couchdb-pytho...@googlegroups.com.--To view this discussion on the web visit https://groups.google.com/d/msg/couchdb-python/-/sFKh8Qt6PhYJ.
You received this message because you are subscribed to the Google Groups "CouchDB-Python" group.
To post to this group, send email to couchdb...@googlegroups.com.
To unsubscribe from this group, send email to couchdb-pytho...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchdb-python?hl=en.
--To view this discussion on the web visit https://groups.google.com/d/msg/couchdb-python/-/kpeiuvjMCp8J.
You received this message because you are subscribed to the Google Groups "CouchDB-Python" group.
To post to this group, send email to couchdb...@googlegroups.com.
To unsubscribe from this group, send email to couchdb-pytho...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchdb-python?hl=en.
--
You received this message because you are subscribed to the Google Groups "CouchDB-Python" group.
To post to this group, send email to couchdb...@googlegroups.com.
To unsubscribe from this group, send email to couchdb-pytho...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/couchdb-python?hl=en.