It's good thing to review your own code after some time passed. This update includes a lot of fixes and even some new features:
global: - removed global state and cross module references (WOO-HOO!) - rewritten QueryServer api - added SimpleQueryServer as high level abstraction on top of QS internals - added MockQueryServer to help write unittests - fix docstring and typos. - query server logs are more useful now in debug mode - update documentation with android paragraph and how to customize query server - place TODO references to actual CouchDB issues: COUCHDB-729, COUCHDB-282, COUCHDB-1261, COUCHDB-898. I could fix them locally, but this will make more differences between original JS server and Python one. - add more over 170 test cases
compiler: - fix crush for compilation of source code with windows newlines - fix double crush if function compilation failed - fix crush for malformed base64 encoded egg - fix crush on egg cache usage - code refactoring
stream: - abstraction from JSON module exception type on decode/encode operations
render: - fix COUCHDB-1272 - code refactoring
validate: - prevent query server crush by validate_doc_update on Python exceptions
views: - reduce_output_overflow error now will be raised properly - small refactoring - document seal now works better with copy.deepcopy()
design functions: - send(), start(), provides(), register_type() available only for show and list functions - get_row() available only for list functions - log() function is not proxy of logging.info anymore
All test passed for: - Python 2.4 to 2.7 - PyPy 1.5 and 1.6 - Android 2.3.4 with Python for Android version 5 against CouchDB-1.0, andorid-0.1 and MobileFuton 1.7
Please, could someone review docstrings and sphinx docs? I'm sure documentation text is far from good state /:
I looked at the queryserver.zip from comment 25 and the files from comment 6. It seems to me that the former is too large and complex to take into couchdb-python at this time. The stuff from comment 6 is much more simple, but I couldn't run the test suite due to the above issue.
Finally, the code in comment 6 does a bunch of stuff to stay compatible with all of 0.9, 0.10 and 0.11+. I would propose that any new view server code we take for our next release be limited to supporting 0.11+-compatible; that's already quite old at this point.
Thanks for first review(: Actually, I never run it as subprocess, but if you take a look at couchdb/tests/testutil.py::QueryServer so it could be run as subprocess, just remove shell=True from Popen.
There is a huge difference between comment 6 and comment 25. It's not in code size, it's in bugs, code complexity, documentation, tests, features, logging and how easily you could extend it without getting things broken. Support of old CouchDB releases is not a little part of it, just a few functions that easily could be removed. For example, I've easily added multiprocessing support for qs#25 for map/reduce functions just by decorating server/views.py functions without touching source code.
Also, you have to change a look from comment 6 to comment 22. That was the last version of all-in-one-file queryserver, but it still buggy by design.
Main goal of qs#25 and all code splitting was to simplify future support, allow to extend it easy and help with couchapps unittesting because now you could run it not as subprocess. And it had been reached.
You may read changelogs in this thread and in my clone at viewserver branch, they are quite full.
I admit, that it's a little big patch for about 250KB of code(removing docstrings could reduce it by half I sure), but I'd like to take support of it, because I use it for everyday tasks, I knew each line of it, I'd like to help couchdb-python project and I do not want to create yet-another-python-queryserver-project. Peoples knows about couchdb-python, knows about his viewserver and expecting that it's fine. Why not to satisfy them?
Updated Python query server in attachments. After almost year usage in
production there was fixed some small problems:
- Eventually crush on chunk encoding for _list functions.
- View lib cleanup on reset command
- Handle single named MIME type params e.g. application/pdf;base64
- Reduced useless logging output to improve they readability.
- Fix COUCHDB-1330.
- Fix crush on malformed MIME type.
- Couchapp modules no more needed to be wrapped into some scope: just write
Python code for them. For example: