Code Monkey home page Code Monkey logo

Comments (7)

nicolaiarocci avatar nicolaiarocci commented on May 10, 2024

Excellent, thanks! Will review as soon as possible.

from eve.

undefzx avatar undefzx commented on May 10, 2024

And little addon - json.dumps not support bson.ObjectIt, but bson.json_util does
I think something like this will work:
from bson.json_util import dumps
dumps(value, sort_keys=True)

from eve.

nicolaiarocci avatar nicolaiarocci commented on May 10, 2024

Good call. However, have you actually seen the documents sorted differently upon restart/different server instances? I ask because I was under the impression that PyMongo/BSON documents use the SON class, which is basically a backport of Py3x/27 OrderedDict (I didn't verify it carefully though).

from eve.

LarryEitel avatar LarryEitel commented on May 10, 2024

Not working for me:

from bson.json_util import dumps

Traceback (most recent call last):
  File "<string>", line 1, in <fragment>
ImportError: cannot import name dumps

from eve.

nicolaiarocci avatar nicolaiarocci commented on May 10, 2024

@LarryEitel it should work:

from bson.json_util import dumps

def document_etag(value):
    h = hashlib.sha1()
    h.update(dumps(value, sort_keys=True))
    return h.hexdigest()

Passes all tests (well except test_document_etag of course, which is not updated yet)

from eve.

undefzx avatar undefzx commented on May 10, 2024

"However, have you actually seen the documents sorted differently upon restart/different server instances?"

Yes. I draw form, ajaxing data from form to eve server, and it pass till validation error (required field missing, in my case). I can do this several times with the same result.
Then, I Ctrl-C server and start it again (not closing form) and when I submit my form again, I ran into 412 error from server.

from eve.

nicolaiarocci avatar nicolaiarocci commented on May 10, 2024

Gotcha, will fix.

from eve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.