I've started on a Flask-MongoEngine implementation, allowing you to integrate MongoDB into Flask apps through the mongoengine library: https://bitbucket.org/danjac/flask-mongoengine/src The design is modeled on Flask-SQLAlchemy, with similar extensions e.g. for pagination. There are some issues to resolve due to limitations on the mongoengine design, for example at present it seems to be impossible to easily change the class for the base objects QuerySet used on a Document class. Another issue is testability - as a running MongoDB instance is required, it may be difficult to run the test suite. There is no documentation as yet until the API is a bit more solid. If anyone else is working on a similar extension please let me know so we can combine rather than duplicate efforts.
Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : > I've started on a Flask-MongoEngine implementation, allowing you to > integrate MongoDB into Flask apps through the mongoengine library: > > https://bitbucket.org/danjac/flask-mongoengine/src > > The design is modeled on Flask-SQLAlchemy, with similar extensions > e.g. for pagination. There are some issues to resolve due to > limitations on the mongoengine design, for example at present it seems > to be impossible to easily change the class for the base objects > QuerySet used on a Document class. Another issue is testability - as a > running MongoDB instance is required, it may be difficult to run the > test suite. > > There is no documentation as yet until the API is a bit more solid. > > If anyone else is working on a similar extension please let me know so > we can combine rather than duplicate efforts. I'm working with mongoengine in a Flask project right now. mongoengine pattern looks nice but there are many limitations. For example it's impossible to embed trees. I've reconsidered using it and started building another ODM based on a quite similar pattern (Document / Field(validation)) on top off pymongo. It will provide a simple interface to WTForms.
@Jean-Philippe have you got an example of your ODM for PyMongo? I've been using PyMongo and really like it, but would like to be able to define my collection models. I've had a look at both MongoKit and MongoEngine, which are good, but would rather not have to use them if possible. On Sat, Sep 18, 2010 at 10:34 PM, Jean-Philippe Serafin < jean-philippe.serafin@dev-solutions.fr> wrote: > Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : > > I've started on a Flask-MongoEngine implementation, allowing you to > > integrate MongoDB into Flask apps through the mongoengine library: > > > > https://bitbucket.org/danjac/flask-mongoengine/src > > > > The design is modeled on Flask-SQLAlchemy, with similar extensions > > e.g. for pagination. There are some issues to resolve due to > > limitations on the mongoengine design, for example at present it seems > > to be impossible to easily change the class for the base objects > > QuerySet used on a Document class. Another issue is testability - as a > > running MongoDB instance is required, it may be difficult to run the > > test suite. > > > > There is no documentation as yet until the API is a bit more solid. > > > > If anyone else is working on a similar extension please let me know so > > we can combine rather than duplicate efforts. > > I'm working with mongoengine in a Flask project right now. mongoengine > pattern looks nice but there are many limitations. For example it's > impossible to embed trees. > > I've reconsidered using it and started building another ODM based on a > quite similar pattern (Document / Field(validation)) on top off pymongo. > It will provide a simple interface to WTForms. > > >
Le dimanche 19 septembre 2010 à 22:37 +1000, Aaron Moodie a écrit : > @Jean-Philippe > > > have you got an example of your ODM for PyMongo? I've been > using PyMongo and really like it, but would like to be able to define > my collection models. I've had a look at both MongoKit and > MongoEngine, which are good, but would rather not have to use them if > possible. > realy realy realy alpha : http://github.com/jean-philippe/mongodm/blob/master//tests.py I'm working on WTForms compatible validators to easily build forms on to of this. > On Sat, Sep 18, 2010 at 10:34 PM, Jean-Philippe Serafin > <jean-philippe.serafin@dev-solutions.fr> wrote: > Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : > > > I've started on a Flask-MongoEngine implementation, allowing > you to > > integrate MongoDB into Flask apps through the mongoengine > library: > > > > https://bitbucket.org/danjac/flask-mongoengine/src > > > > The design is modeled on Flask-SQLAlchemy, with similar > extensions > > e.g. for pagination. There are some issues to resolve due to > > limitations on the mongoengine design, for example at > present it seems > > to be impossible to easily change the class for the base > objects > > QuerySet used on a Document class. Another issue is > testability - as a > > running MongoDB instance is required, it may be difficult to > run the > > test suite. > > > > There is no documentation as yet until the API is a bit more > solid. > > > > If anyone else is working on a similar extension please let > me know so > > we can combine rather than duplicate efforts. > > > I'm working with mongoengine in a Flask project right now. > mongoengine > pattern looks nice but there are many limitations. For example > it's > impossible to embed trees. > > I've reconsidered using it and started building another ODM > based on a > quite similar pattern (Document / Field(validation)) on top > off pymongo. > It will provide a simple interface to WTForms. > > > >
Le dimanche 19 septembre 2010 à 22:37 +1000, Aaron Moodie a écrit : > @Jean-Philippe > > > have you got an example of your ODM for PyMongo? I've been > using PyMongo and really like it, but would like to be able to define > my collection models. I've had a look at both MongoKit and > MongoEngine, which are good, but would rather not have to use them if > possible. > It's not currently stable... also I'm trying to integrate @Anton pattern to only use pymongo for querying. > On Sat, Sep 18, 2010 at 10:34 PM, Jean-Philippe Serafin > <jean-philippe.serafin@dev-solutions.fr> wrote: > Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : > > > I've started on a Flask-MongoEngine implementation, allowing > you to > > integrate MongoDB into Flask apps through the mongoengine > library: > > > > https://bitbucket.org/danjac/flask-mongoengine/src > > > > The design is modeled on Flask-SQLAlchemy, with similar > extensions > > e.g. for pagination. There are some issues to resolve due to > > limitations on the mongoengine design, for example at > present it seems > > to be impossible to easily change the class for the base > objects > > QuerySet used on a Document class. Another issue is > testability - as a > > running MongoDB instance is required, it may be difficult to > run the > > test suite. > > > > There is no documentation as yet until the API is a bit more > solid. > > > > If anyone else is working on a similar extension please let > me know so > > we can combine rather than duplicate efforts. > > > I'm working with mongoengine in a Flask project right now. > mongoengine > pattern looks nice but there are many limitations. For example > it's > impossible to embed trees. > > I've reconsidered using it and started building another ODM > based on a > quite similar pattern (Document / Field(validation)) on top > off pymongo. > It will provide a simple interface to WTForms. > > > >
I've gone with mongoengine to avoid reinventing the wheel, however not sure if it's production quality yet given its limitations. On 18 September 2010 13:34, Jean-Philippe Serafin <jean-philippe.serafin@dev-solutions.fr> wrote: > Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : >> I've started on a Flask-MongoEngine implementation, allowing you to >> integrate MongoDB into Flask apps through the mongoengine library: >> >> https://bitbucket.org/danjac/flask-mongoengine/src >> >> The design is modeled on Flask-SQLAlchemy, with similar extensions >> e.g. for pagination. There are some issues to resolve due to >> limitations on the mongoengine design, for example at present it seems >> to be impossible to easily change the class for the base objects >> QuerySet used on a Document class. Another issue is testability - as a >> running MongoDB instance is required, it may be difficult to run the >> test suite. >> >> There is no documentation as yet until the API is a bit more solid. >> >> If anyone else is working on a similar extension please let me know so >> we can combine rather than duplicate efforts. > > I'm working with mongoengine in a Flask project right now. mongoengine > pattern looks nice but there are many limitations. For example it's > impossible to embed trees. > > I've reconsidered using it and started building another ODM based on a > quite similar pattern (Document / Field(validation)) on top off pymongo. > It will provide a simple interface to WTForms. > > >
I'm also using MongoDB, but with PyMongo. I tried both MongoKit and MongoEngine, and came to a conclusion that none of these two ODM provide as much functionality as they hide. Atomic updates provide me much more flexibility, plus they are quite readable. For easier access to Python dicts/lists I use my own dot-lookup class. So instead of >> d = dict(); d['a'] = 1; print d['a]; I would use >> d = dict(); d.a = 1; print d.a; And for data validation I also use my own bicycle - a class with a schema a la MongoKit. So far I'm pretty happy with MongoDB and with my approach in general. On Sep 18, 2010, at 6:13 PM, Dan Jacob wrote: > I've gone with mongoengine to avoid reinventing the wheel, however not > sure if it's production quality yet given its limitations. > > On 18 September 2010 13:34, Jean-Philippe Serafin > <jean-philippe.serafin@dev-solutions.fr> wrote: >> Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : >>> I've started on a Flask-MongoEngine implementation, allowing you to >>> integrate MongoDB into Flask apps through the mongoengine library: >>> >>> https://bitbucket.org/danjac/flask-mongoengine/src >>> >>> The design is modeled on Flask-SQLAlchemy, with similar extensions >>> e.g. for pagination. There are some issues to resolve due to >>> limitations on the mongoengine design, for example at present it seems >>> to be impossible to easily change the class for the base objects >>> QuerySet used on a Document class. Another issue is testability - as a >>> running MongoDB instance is required, it may be difficult to run the >>> test suite. >>> >>> There is no documentation as yet until the API is a bit more solid. >>> >>> If anyone else is working on a similar extension please let me know so >>> we can combine rather than duplicate efforts. >> >> I'm working with mongoengine in a Flask project right now. mongoengine >> pattern looks nice but there are many limitations. For example it's >> impossible to embed trees. >> >> I've reconsidered using it and started building another ODM based on a >> quite similar pattern (Document / Field(validation)) on top off pymongo. >> It will provide a simple interface to WTForms. >> >> >>
Le samedi 18 septembre 2010 à 18:29 +0300, Anton Khodakivskiy a écrit : > I'm also using MongoDB, but with PyMongo. I tried both MongoKit and MongoEngine, and came to a conclusion that none of these two ODM provide as much functionality as they hide. Atomic updates provide me much more flexibility, plus they are quite readable. > > For easier access to Python dicts/lists I use my own dot-lookup class. So instead of > > >> d = dict(); d['a'] = 1; print d['a]; > I would use > >> d = dict(); d.a = 1; print d.a; > > And for data validation I also use my own bicycle - a class with a schema a la MongoKit. So far I'm pretty happy with MongoDB and with my approach in general. > I think defining document fields and validators in the same schema is the best practice (<strike>mongokit</strike>) because it's more easy to integrate in forms framemork (like WTForms) and it's a more Object Oriented point of view. > On Sep 18, 2010, at 6:13 PM, Dan Jacob wrote: > > > I've gone with mongoengine to avoid reinventing the wheel, however not > > sure if it's production quality yet given its limitations. > > > > On 18 September 2010 13:34, Jean-Philippe Serafin > > <jean-philippe.serafin@dev-solutions.fr> wrote: > >> Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : > >>> I've started on a Flask-MongoEngine implementation, allowing you to > >>> integrate MongoDB into Flask apps through the mongoengine library: > >>> > >>> https://bitbucket.org/danjac/flask-mongoengine/src > >>> > >>> The design is modeled on Flask-SQLAlchemy, with similar extensions > >>> e.g. for pagination. There are some issues to resolve due to > >>> limitations on the mongoengine design, for example at present it seems > >>> to be impossible to easily change the class for the base objects > >>> QuerySet used on a Document class. Another issue is testability - as a > >>> running MongoDB instance is required, it may be difficult to run the > >>> test suite. > >>> > >>> There is no documentation as yet until the API is a bit more solid. > >>> > >>> If anyone else is working on a similar extension please let me know so > >>> we can combine rather than duplicate efforts. > >> > >> I'm working with mongoengine in a Flask project right now. mongoengine > >> pattern looks nice but there are many limitations. For example it's > >> impossible to embed trees. > >> > >> I've reconsidered using it and started building another ODM based on a > >> quite similar pattern (Document / Field(validation)) on top off pymongo. > >> It will provide a simple interface to WTForms. > >> > >> > >> >
WTForms use their own validation layer. Or is there a way to integrate a custom validation into it? In my setup i don't even have the notion of a document. While updating/saving the affected fields only are validated, and then pushed into the database. While querying it will return dict/list tree wrapped into that dot-looup class I mentioned. Very nice feature of pymongo is the document_class arg: http://api.mongodb.org/python/1.8.1%2B/api/pymongo/connection.html#pymongo.connection.Connection.document_class On Sep 18, 2010, at 7:02 PM, Jean-Philippe Serafin wrote: > Le samedi 18 septembre 2010 à 18:29 +0300, Anton Khodakivskiy a écrit : >> I'm also using MongoDB, but with PyMongo. I tried both MongoKit and MongoEngine, and came to a conclusion that none of these two ODM provide as much functionality as they hide. Atomic updates provide me much more flexibility, plus they are quite readable. >> >> For easier access to Python dicts/lists I use my own dot-lookup class. So instead of >> >>>> d = dict(); d['a'] = 1; print d['a]; >> I would use >>>> d = dict(); d.a = 1; print d.a; >> >> And for data validation I also use my own bicycle - a class with a schema a la MongoKit. So far I'm pretty happy with MongoDB and with my approach in general. >> > > I think defining document fields and validators in the same schema is > the best practice (<strike>mongokit</strike>) because it's more easy to > integrate in forms framemork (like WTForms) and it's a more Object > Oriented point of view. > >> On Sep 18, 2010, at 6:13 PM, Dan Jacob wrote: >> >>> I've gone with mongoengine to avoid reinventing the wheel, however not >>> sure if it's production quality yet given its limitations. >>> >>> On 18 September 2010 13:34, Jean-Philippe Serafin >>> <jean-philippe.serafin@dev-solutions.fr> wrote: >>>> Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : >>>>> I've started on a Flask-MongoEngine implementation, allowing you to >>>>> integrate MongoDB into Flask apps through the mongoengine library: >>>>> >>>>> https://bitbucket.org/danjac/flask-mongoengine/src >>>>> >>>>> The design is modeled on Flask-SQLAlchemy, with similar extensions >>>>> e.g. for pagination. There are some issues to resolve due to >>>>> limitations on the mongoengine design, for example at present it seems >>>>> to be impossible to easily change the class for the base objects >>>>> QuerySet used on a Document class. Another issue is testability - as a >>>>> running MongoDB instance is required, it may be difficult to run the >>>>> test suite. >>>>> >>>>> There is no documentation as yet until the API is a bit more solid. >>>>> >>>>> If anyone else is working on a similar extension please let me know so >>>>> we can combine rather than duplicate efforts. >>>> >>>> I'm working with mongoengine in a Flask project right now. mongoengine >>>> pattern looks nice but there are many limitations. For example it's >>>> impossible to embed trees. >>>> >>>> I've reconsidered using it and started building another ODM based on a >>>> quite similar pattern (Document / Field(validation)) on top off pymongo. >>>> It will provide a simple interface to WTForms. >>>> >>>> >>>> >> > > > >
What limitations did you have with MongoKit vs MongoEngine ? On 18 September 2010 17:02, Jean-Philippe Serafin <jean-philippe.serafin@dev-solutions.fr> wrote: > Le samedi 18 septembre 2010 à 18:29 +0300, Anton Khodakivskiy a écrit : >> I'm also using MongoDB, but with PyMongo. I tried both MongoKit and MongoEngine, and came to a conclusion that none of these two ODM provide as much functionality as they hide. Atomic updates provide me much more flexibility, plus they are quite readable. >> >> For easier access to Python dicts/lists I use my own dot-lookup class. So instead of >> >> >> d = dict(); d['a'] = 1; print d['a]; >> I would use >> >> d = dict(); d.a = 1; print d.a; >> >> And for data validation I also use my own bicycle - a class with a schema a la MongoKit. So far I'm pretty happy with MongoDB and with my approach in general. >> > > I think defining document fields and validators in the same schema is > the best practice (<strike>mongokit</strike>) because it's more easy to > integrate in forms framemork (like WTForms) and it's a more Object > Oriented point of view. > >> On Sep 18, 2010, at 6:13 PM, Dan Jacob wrote: >> >> > I've gone with mongoengine to avoid reinventing the wheel, however not >> > sure if it's production quality yet given its limitations. >> > >> > On 18 September 2010 13:34, Jean-Philippe Serafin >> > <jean-philippe.serafin@dev-solutions.fr> wrote: >> >> Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : >> >>> I've started on a Flask-MongoEngine implementation, allowing you to >> >>> integrate MongoDB into Flask apps through the mongoengine library: >> >>> >> >>> https://bitbucket.org/danjac/flask-mongoengine/src >> >>> >> >>> The design is modeled on Flask-SQLAlchemy, with similar extensions >> >>> e.g. for pagination. There are some issues to resolve due to >> >>> limitations on the mongoengine design, for example at present it seems >> >>> to be impossible to easily change the class for the base objects >> >>> QuerySet used on a Document class. Another issue is testability - as a >> >>> running MongoDB instance is required, it may be difficult to run the >> >>> test suite. >> >>> >> >>> There is no documentation as yet until the API is a bit more solid. >> >>> >> >>> If anyone else is working on a similar extension please let me know so >> >>> we can combine rather than duplicate efforts. >> >> >> >> I'm working with mongoengine in a Flask project right now. mongoengine >> >> pattern looks nice but there are many limitations. For example it's >> >> impossible to embed trees. >> >> >> >> I've reconsidered using it and started building another ODM based on a >> >> quite similar pattern (Document / Field(validation)) on top off pymongo. >> >> It will provide a simple interface to WTForms. >> >> >> >> >> >> >> > > > > >
I think MongoKit has less limitations, since its mongokit.Document class inherits pymongo.Document, and you can actually do whatever you do with pymongo. MongoEngine provides new interface to everything, including atomic updates. I did not like the validation capabilities of both ODMs - they either validate everything, or none. Sometimes I just want to validate one field, not the whole document( which might be quite big! ) Most of the time I would use db.update(...) to push the user input into the database (with prior validation). The ODM require you to pull the whole document, set values, validate, and then save it back, which will probably use db.save(...) I also had some hard time referencing documents with (Generic)ReferenceField/use_autorefs: if the document is referenced not by _id, but by some other field then these features can not be used. And again, using them imposes quite a bit of overhead. So my overall impression is that the ODMs do not provide as much as they require you to do. I also do not want to create a mix of ODM and pymongo code. If I had to select one of the two I would opt for MongoKit. On Sep 18, 2010, at 7:05 PM, Dan Jacob wrote: > What limitations did you have with MongoKit vs MongoEngine ? > > On 18 September 2010 17:02, Jean-Philippe Serafin > <jean-philippe.serafin@dev-solutions.fr> wrote: >> Le samedi 18 septembre 2010 à 18:29 +0300, Anton Khodakivskiy a écrit : >>> I'm also using MongoDB, but with PyMongo. I tried both MongoKit and MongoEngine, and came to a conclusion that none of these two ODM provide as much functionality as they hide. Atomic updates provide me much more flexibility, plus they are quite readable. >>> >>> For easier access to Python dicts/lists I use my own dot-lookup class. So instead of >>> >>>>> d = dict(); d['a'] = 1; print d['a]; >>> I would use >>>>> d = dict(); d.a = 1; print d.a; >>> >>> And for data validation I also use my own bicycle - a class with a schema a la MongoKit. So far I'm pretty happy with MongoDB and with my approach in general. >>> >> >> I think defining document fields and validators in the same schema is >> the best practice (<strike>mongokit</strike>) because it's more easy to >> integrate in forms framemork (like WTForms) and it's a more Object >> Oriented point of view. >> >>> On Sep 18, 2010, at 6:13 PM, Dan Jacob wrote: >>> >>>> I've gone with mongoengine to avoid reinventing the wheel, however not >>>> sure if it's production quality yet given its limitations. >>>> >>>> On 18 September 2010 13:34, Jean-Philippe Serafin >>>> <jean-philippe.serafin@dev-solutions.fr> wrote: >>>>> Le samedi 18 septembre 2010 à 13:08 +0100, Dan Jacob a écrit : >>>>>> I've started on a Flask-MongoEngine implementation, allowing you to >>>>>> integrate MongoDB into Flask apps through the mongoengine library: >>>>>> >>>>>> https://bitbucket.org/danjac/flask-mongoengine/src >>>>>> >>>>>> The design is modeled on Flask-SQLAlchemy, with similar extensions >>>>>> e.g. for pagination. There are some issues to resolve due to >>>>>> limitations on the mongoengine design, for example at present it seems >>>>>> to be impossible to easily change the class for the base objects >>>>>> QuerySet used on a Document class. Another issue is testability - as a >>>>>> running MongoDB instance is required, it may be difficult to run the >>>>>> test suite. >>>>>> >>>>>> There is no documentation as yet until the API is a bit more solid. >>>>>> >>>>>> If anyone else is working on a similar extension please let me know so >>>>>> we can combine rather than duplicate efforts. >>>>> >>>>> I'm working with mongoengine in a Flask project right now. mongoengine >>>>> pattern looks nice but there are many limitations. For example it's >>>>> impossible to embed trees. >>>>> >>>>> I've reconsidered using it and started building another ODM based on a >>>>> quite similar pattern (Document / Field(validation)) on top off pymongo. >>>>> It will provide a simple interface to WTForms. >>>>> >>>>> >>>>> >>> >> >> >> >> >>