Skip to content

Basic update handler support. #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed

Basic update handler support. #268

wants to merge 6 commits into from

Conversation

mefyl
Copy link

@mefyl mefyl commented Aug 12, 2015

Same player play again, passing Travis build, with a unit test and some doc.

Implementation for some of the ddoc query server call, enabling to write update handlers in python. I'm very new to CouchDB so this might be incomplete, but it works for me so far. I might keep adding support as my needs evolve.

@mefyl
Copy link
Author

mefyl commented Aug 12, 2015

Note: I'm not sure why I had to patch infinit@acbfded , but in my setup (Python 3.4.1, CouchDB 1.6.1) the output stream of the query server is text, not binary. Could be the way CouchDB starts the subprocess ? Some subtle Python difference in the way it determines whether stdin is text ? Anyway it fixes it for me and hopefully doesn't break it for other, but some double check would be a good idea.

@kxepal
Copy link
Collaborator

kxepal commented Aug 12, 2015

That's completely incorrect implementation. See JavaScript query server, his tests or my fork where it's done.

@mefyl
Copy link
Author

mefyl commented Aug 12, 2015

I don't think "completely incorrect" is an even remotely appropriated comment. As I stated, it's partial and I'm building it as I go just to fill-in the missing feature. Now, if you have a working version - which I didn't know - I'd be more than glad to just see it merged here and use it.

If there is a fundamental flaw in the way I started implementing this, a few line stating why would be helpful. I certainly don't expect it to pass the test suite you mentionned since I implemented a small subset of the ddoc feature.

@kxepal
Copy link
Collaborator

kxepal commented Aug 12, 2015

@mefyl it's "incorrect" because:

  1. update functions doesn't have two level function definition like views (e.g. there is no "map")
  2. they should forbid GET requests in order to not let things go wrong
  3. resp part need to wrap strings with {"body": ...} object

"Completely" is because it's incompatible with the way how javascript ones works and breaks common ddoc structure what will prevent you simply backport any JS couchapp to Python.

Sorry for not describing "why" in my reply.

@kxepal
Copy link
Collaborator

kxepal commented Aug 12, 2015

Now, if you have a working version - which I didn't know - I'd be more than glad to just see it merged here and use it.

Well, I stopped work on it long time ago because it's done, but it unlikely be merged because of commit history policy. So it's just there for history and for others who want to implement it again (:

@mefyl
Copy link
Author

mefyl commented Aug 12, 2015

Thanks for the precisions !

  1. True, my design docs erroneously had this map indirection, so I ended up thinking that was the CouchDB format. I'll fix it right away. The documentation isn't really rigorous/complete, so one has to do some reverse-engineering on the protocol :-|
  2. Sure thing, although I would count that as an improvement, not a "bug" in a first partial implementation :)
  3. Well, I partly disagree on that one: the documentation for ResponseObject states you can use json instead of body and add headers or several other useful fields, so I left it to the update handler to return {body: ...} or any other combination (the doc I added reflects this). It is true I could wrap plain strings with {body: ...} so you can just return strings while not preventing the other features. Opinion welcomed.

About the "incompatible with javascript" part, are we talking about the erroneous map key ? If so, it's definitely a mistake I'm fixing.

Understand my process here is to implement the features on the go as I can't sit down one week with specs to implement this, so it will be incremental and inferior to a full implementation for some time. Your code will certainly be of help, thanks for pointing me to it.

@djc
Copy link
Owner

djc commented Aug 12, 2015

@kxepal I'm sorry about the commit policy. Can I somehow entice you to do a little work to get the whole thing merged again? I started on it myself once or twice, but it's quite a bit of work and I currently lack the motivation/time to clean things up. However, given that you already know how things ought to work, it seems like a somewhat clean history isn't that much work.

Otherwise, maybe we should contemplate just squashing the whole thing and making sure the end state makes sense. Let's iterate on it together?

@kxepal
Copy link
Collaborator

kxepal commented Aug 12, 2015

@djc No need to sorry: it's good that you have and require commits to met high, good, standards. I respect this and eventually try to follow the same rules. The main problem is that it's very boring to reorganize 50+ commits of iterative work and hard to keep all things consistent after conflicts. Today when I look on those code again, I wish I would at least clean it and fix the style: 4 years is quite a lot of time to change the views on Python coding.

I see two ways to handle it:

  • Reorganize commits to make history more or less clear and make their share right. It would be hard because there iirc there were three versions which evolved one to another: one big view.py -> server subpackage -> stateless design. In the middle new features were added while existed bugs were fixed.
  • Just squash all the stuff and move important bits from commit messages into code commentaries and doc strings. Most simple way to go and it will force to pay more attention to code review, but will produce one massive commit. However, not sure if any history will be important if the code itself will be well documented.

P.S. Sorry for my initial attitude here, it seems I wasn't in good mood to be polite.

@djc
Copy link
Owner

djc commented Aug 13, 2015

@kxepal can we just go straight to implementing the stateless design? With the policy I have in mind, the goal is not to reflect exactly the history of development. The goal is only to have commits that are understandable as a unit, that work towards the goal of the series, and ideally are easily reviewable (which implies some upper bound on size, ideally). I may not have expressed this clearly before. So what I don't like is having the extra bug-fixing commits in the history; those should be squashed into the commit that introduced the bug. Would this make it easier?

Thanks for the apology, accepted. Everyone can have a bad day!

@kxepal
Copy link
Collaborator

kxepal commented Aug 13, 2015

@djc you know....I walk over the history, read the code and found that the only way to make it work and don't feel the shame about, is to cut the latest code version into consistent commits. I have the following plan in my head now:

  • 1 commit to turn view.py into server subpackage
  • 1 commit per design function
  • 1 commit per new feature
  • 1 commit per important bug fix (those which are couchdb-* )
    Sounds good for you?

I just imported viewserver branch to GitHub to make it easy estimate all the tragedy (:

@mefyl
Copy link
Author

mefyl commented Aug 13, 2015

No offense taken either; if your implementation is being merged, I'll stand by waiting for it. As I stated, there is still infinit@acbfded that is require for the server to work at all in my setup, so maybe just this patch should be considered ?

(also the short sha1 is a permutation of abcdef, that should make it worth keeping)

@djc
Copy link
Owner

djc commented Aug 13, 2015

@kxepal that sounds awesome!! I'd love to get that merged.

@mefyl sorry to side-track your pull request, and sorry if your work doesn't end up being used in the project. Still, your pull request has been instrumental in landing a better view server, so I hope you're getting a good deal in the end. I bet @kxepal will look at your pull request if he has problems getting his work to pass with Python 3.

@mefyl
Copy link
Author

mefyl commented Aug 13, 2015

I have no pride in seeing MY code merged, if I too get a fully featured view server at no development cost, it's even better :)

iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request Mar 22, 2016
- Add `server/exceptions.py`

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- Rename `ViewServerException` to `QueryServerException`

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request Mar 22, 2016
Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- Add `input` and `ouput` into `BaseQueryServer.__init__`
  parameters list.

- pep8 coding style checked with
  $ pep8 --max-line-length=100 --show-source --first

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request Apr 12, 2016
In `__init__.py`,
we implements Python query server with high level API.

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- pep8 coding style checked with
  $ pep8 --max-line-length=100 --show-source --first

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
Start to work on callable command line interface of
query server package.

Author:     Alexander Shorin <kxepal@gmail.com>

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
- Add `server/exceptions.py`

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- Rename `ViewServerException` to `QueryServerException`

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- Add `input` and `ouput` into `BaseQueryServer.__init__`
  parameters list.

- pep8 coding style checked with
  $ pep8 --max-line-length=100 --show-source --first

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
In `__init__.py`,
we implements Python query server with high level API.

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- pep8 coding style checked with
  $ pep8 --max-line-length=100 --show-source --first

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
Start to work on callable command line interface of
query server package.

Author:     Alexander Shorin <kxepal@gmail.com>

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
Start to work on callable command line interface of
query server package.

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- Change the entry points of query server in setup.py

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 9, 2016
Start to work on callable command line interface of
query server package.

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <e196819@hotmail.com>

- Change the entry points of query server in setup.py

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 15, 2016
Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <iblis@hs.ntnu.edu.tw>

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 15, 2016
- Test case inclueded

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <iblis@hs.ntnu.edu.tw>

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 15, 2016
- Test cases included

Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <iblis@hs.ntnu.edu.tw>

Reference: djc#268
See Also:  djc#276
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request May 15, 2016
Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <iblis@hs.ntnu.edu.tw>

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
The `output` parameter of `stream.respond` should be writable
with unicode.

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 20, 2016
Drop the support for python25 or below

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 21, 2016
We also take care the new log format.

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 22, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 23, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 23, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 24, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 28, 2016
We take care the case of
"user really want a empty dictionary as `context`".

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 28, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request May 30, 2016
compiler.
test_required_modules_has_global_namespace_access

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Jun 6, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Jun 11, 2016
- The output is key-value pair only
- Also, provide comprehensive message

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Jun 23, 2016
@djc
Copy link
Owner

djc commented Aug 5, 2016

This will be done as part of #286, closing.

@djc djc closed this Aug 5, 2016
iblislin pushed a commit to iblislin/couchdb-python that referenced this pull request Oct 25, 2016
Author:     Alexander Shorin <kxepal@gmail.com>
Patched by: Iblis Lin <iblis@hs.ntnu.edu.tw>

Reference: djc#268
See Also:  djc#276
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Oct 25, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Oct 25, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Oct 25, 2016
iblislin added a commit to iblislin/couchdb-python that referenced this pull request Oct 26, 2016
- Remove duplicate xhtml
- Introduce type aliases for `DEFAULT_TYPES`,
  e.g. `('text', 'txt'): ['text/plain; charset=utf-8']`.
  `txt` is an alias of `text`.

Reference: djc#268
See Also:  djc#276
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants