librelist archives

« back to archive

Flask, Mongo

Flask, Mongo

From:
Serge S. Koval
Date:
2012-10-30 @ 11:20
Hi,

 As author of the Flask-Admin package, I want to add MongoDB backend. I can
just rely on pymongo and scaffold interface based on input parameters (list
of fields to display in list view, etc), but have few questions:
1. If you use MongoDB, do you use any kind of ORM? If yes, which one?
(MongoAlchemy, MongoEngine, etc)
2. Do you use plain pymongo? If yes, do you just work with dictionaries or
do some kind of schema mapping between your application and MongoDB records?

Thanks,
Serge.

Re: [flask] Flask, Mongo

From:
Gustavo Gawryszewski
Date:
2012-10-30 @ 12:33
I use with MongoEngine 

-- 
Gustavo Gawryszewski


On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:

> 
>  As author of the Flask-Admin package, I want to add MongoDB backend. I 
can just rely on pymongo and scaffold interface based on input parameters 
(list of fields to display in list view, etc), but have few questions:
> 1. If you use MongoDB, do you use any kind of ORM? If yes, which one? 
(MongoAlchemy, MongoEngine, etc)
> 2. Do you use plain pymongo? If yes, do you just work with dictionaries 
or do some kind of schema mapping between your application and MongoDB 
records?
> 

Re: [flask] Flask, Mongo

From:
Marcus Carlsson
Date:
2012-10-30 @ 12:48
On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
> I use with MongoEngine 
> 
> -- 
> Gustavo Gawryszewski
> 
> 
> On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
> 
> > 
> >  As author of the Flask-Admin package, I want to add MongoDB backend. 
I can just rely on pymongo and scaffold interface based on input 
parameters (list of fields to display in list view, etc), but have few 
questions:
> > 1. If you use MongoDB, do you use any kind of ORM? If yes, which one? 
(MongoAlchemy, MongoEngine, etc)
> > 2. Do you use plain pymongo? If yes, do you just work with 
dictionaries or do some kind of schema mapping between your application 
and MongoDB records?
> > 
> 
+1 for MongoEngine
-- 
Marcus Carlsson
http://xintron.se

Re: [flask] Flask, Mongo

From:
Chris Higgins
Date:
2012-10-30 @ 14:29
I'm going to say +1 more for MongoEngine.

-----Original Message-----
From: flask@librelist.com [mailto:flask@librelist.com] On Behalf Of Marcus
Carlsson
Sent: Tuesday, October 30, 2012 7:48 AM
To: flask@librelist.com
Subject: Re: [flask] Flask, Mongo

On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
> I use with MongoEngine
> 
> --
> Gustavo Gawryszewski
> 
> 
> On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
> 
> > 
> >  As author of the Flask-Admin package, I want to add MongoDB backend. I
can just rely on pymongo and scaffold interface based on input parameters
(list of fields to display in list view, etc), but have few questions:
> > 1. If you use MongoDB, do you use any kind of ORM? If yes, which 
> > one? (MongoAlchemy, MongoEngine, etc) 2. Do you use plain pymongo? If
yes, do you just work with dictionaries or do some kind of schema mapping
between your application and MongoDB records?
> > 
> 
+1 for MongoEngine
--
Marcus Carlsson
http://xintron.se

Re: [flask] Flask, Mongo

From:
pronoyc@gmail.com
Date:
2012-10-30 @ 14:44
Raw Pymongo. Maybe MongoEngine for data retrieval. But for data insertion
into the db Pymongo raw.

On Tue, Oct 30, 2012 at 7:59 PM, Chris Higgins <chris@chigs.me> wrote:

> I'm going to say +1 more for MongoEngine.
>
> -----Original Message-----
> From: flask@librelist.com [mailto:flask@librelist.com] On Behalf Of Marcus
> Carlsson
> Sent: Tuesday, October 30, 2012 7:48 AM
> To: flask@librelist.com
> Subject: Re: [flask] Flask, Mongo
>
> On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
> > I use with MongoEngine
> >
> > --
> > Gustavo Gawryszewski
> >
> >
> > On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
> >
> > >
> > >  As author of the Flask-Admin package, I want to add MongoDB backend. I
> can just rely on pymongo and scaffold interface based on input parameters
> (list of fields to display in list view, etc), but have few questions:
> > > 1. If you use MongoDB, do you use any kind of ORM? If yes, which
> > > one? (MongoAlchemy, MongoEngine, etc) 2. Do you use plain pymongo? If
> yes, do you just work with dictionaries or do some kind of schema mapping
> between your application and MongoDB records?
> > >
> >
> +1 for MongoEngine
> --
> Marcus Carlsson
> http://xintron.se
>
>


-- 
Regards,

Pronoy Chopra
http://blog.pronoy.in <http://www.pronoy.in/about>/
http://www.twitter.com/pronoyc

Re: [flask] Flask, Mongo

From:
Smartboy
Date:
2012-10-30 @ 16:32
I also use raw Pymongo, but that's mostly because I find ORMs to be rather
clunky in general when used with databases.

As for how I use it, on my last project I wrote my own wrapper around
MongoDB that did just what I needed it to do. It does use dictionaries
inside the wrapper, but on the outside it uses functions with arguments to
get its data. Some may find it unnecessary given ORMs, but for what I
needed, it works.

On Tue, Oct 30, 2012 at 7:44 AM, pronoyc@gmail.com <pronoyc@gmail.com>wrote:

> Raw Pymongo. Maybe MongoEngine for data retrieval. But for data insertion
> into the db Pymongo raw.
>
>
> On Tue, Oct 30, 2012 at 7:59 PM, Chris Higgins <chris@chigs.me> wrote:
>
>> I'm going to say +1 more for MongoEngine.
>>
>> -----Original Message-----
>> From: flask@librelist.com [mailto:flask@librelist.com] On Behalf Of
>> Marcus
>> Carlsson
>> Sent: Tuesday, October 30, 2012 7:48 AM
>> To: flask@librelist.com
>> Subject: Re: [flask] Flask, Mongo
>>
>> On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
>> > I use with MongoEngine
>> >
>> > --
>> > Gustavo Gawryszewski
>> >
>> >
>> > On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
>> >
>> > >
>> > >  As author of the Flask-Admin package, I want to add MongoDB backend.
>> I
>> can just rely on pymongo and scaffold interface based on input parameters
>> (list of fields to display in list view, etc), but have few questions:
>> > > 1. If you use MongoDB, do you use any kind of ORM? If yes, which
>> > > one? (MongoAlchemy, MongoEngine, etc) 2. Do you use plain pymongo? If
>> yes, do you just work with dictionaries or do some kind of schema mapping
>> between your application and MongoDB records?
>> > >
>> >
>> +1 for MongoEngine
>> --
>> Marcus Carlsson
>> http://xintron.se
>>
>>
>
>
> --
> Regards,
>
> Pronoy Chopra
> http://blog.pronoy.in <http://www.pronoy.in/about>/
> http://www.twitter.com/pronoyc
>
>

Re: [flask] Flask, Mongo

From:
Mark Grey
Date:
2012-10-30 @ 16:50
Raw Pymongo here, I think that would be best for something intended as
reusable library code.  Would eliminate the need for additional modules.

I've used minimongo https://github.com/slacy/minimongo at times when I
needed an ORM solution for mongo that was truly lightweight (basically just
wrappers around dictionary representations of documents that methods can be
attached to.)

On Tue, Oct 30, 2012 at 12:32 PM, Smartboy <smartboyathome@gmail.com> wrote:

> I also use raw Pymongo, but that's mostly because I find ORMs to be rather
> clunky in general when used with databases.
>
> As for how I use it, on my last project I wrote my own wrapper around
> MongoDB that did just what I needed it to do. It does use dictionaries
> inside the wrapper, but on the outside it uses functions with arguments to
> get its data. Some may find it unnecessary given ORMs, but for what I
> needed, it works.
>
>
> On Tue, Oct 30, 2012 at 7:44 AM, pronoyc@gmail.com <pronoyc@gmail.com>wrote:
>
>> Raw Pymongo. Maybe MongoEngine for data retrieval. But for data insertion
>> into the db Pymongo raw.
>>
>>
>> On Tue, Oct 30, 2012 at 7:59 PM, Chris Higgins <chris@chigs.me> wrote:
>>
>>> I'm going to say +1 more for MongoEngine.
>>>
>>> -----Original Message-----
>>> From: flask@librelist.com [mailto:flask@librelist.com] On Behalf Of
>>> Marcus
>>> Carlsson
>>> Sent: Tuesday, October 30, 2012 7:48 AM
>>> To: flask@librelist.com
>>> Subject: Re: [flask] Flask, Mongo
>>>
>>> On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
>>> > I use with MongoEngine
>>> >
>>> > --
>>> > Gustavo Gawryszewski
>>> >
>>> >
>>> > On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
>>> >
>>> > >
>>> > >  As author of the Flask-Admin package, I want to add MongoDB
>>> backend. I
>>> can just rely on pymongo and scaffold interface based on input parameters
>>> (list of fields to display in list view, etc), but have few questions:
>>> > > 1. If you use MongoDB, do you use any kind of ORM? If yes, which
>>> > > one? (MongoAlchemy, MongoEngine, etc) 2. Do you use plain pymongo? If
>>> yes, do you just work with dictionaries or do some kind of schema mapping
>>> between your application and MongoDB records?
>>> > >
>>> >
>>> +1 for MongoEngine
>>> --
>>> Marcus Carlsson
>>> http://xintron.se
>>>
>>>
>>
>>
>> --
>> Regards,
>>
>> Pronoy Chopra
>> http://blog.pronoy.in <http://www.pronoy.in/about>/
>> http://www.twitter.com/pronoyc
>>
>>
>

Re: [flask] Flask, Mongo

From:
Shamail Tayyab
Date:
2012-10-30 @ 19:01
Hi,

    +1 MongoEngine too.

Here is some concise usage of MongoEngine that will tell you why I mean it:

class User (Document):    # say
     username = StringField ()
     _profile = ObjectIdField ()

     @property
     def getprofile (self):
         return Profile.objects.get (self._profile)


class Post (Document):
     data = StringField ()
     seostring = StringField ()
     _comments = ListField (ObjectIdField())
     _author = ObjectIdField ()

     @property
     def getcomments (self):
         ordered = []
         comments = Comment.objects.in_bulk (self._comments)  # returns 
a dict
         for i in comments:
             ordered.append (comments.get (i))

         # Lets put authors in one go..
         authors = map (lambda x: x._author, ordered)
         author_objs = User.objects.in_bulk (authors)
         for i in ordered:
             i.author = author_objs.get (i._author)
         return ordered


class Comment (Document):
     data = StringField ()
     _author = ObjectIdField ()


# Call like
post = Post.objects.get (seostring = "fantastic_post")

# And a render like this (in django's syntax, with flask I use Jade, so 
don't know much of the inbuilt templater)
#
# <p> {{ post.data }} </p>
# <ul>
# {% for c in post.getcomments %}
#   <li> {{c.data}} - {{c.author}} </li>
# {% endfor %}
# </ul>
#
# Will use only 2 lookups.

MongoEngine helps keep the abstraction of dirty code within; with 
pymongo, organization is not so oopic (unless you explicitly do it 
yourself by-hand).

Hope that helps..

Tx

--
Shamail Tayyab

On 30/10/12 7:59 PM, Chris Higgins wrote:
> I'm going to say +1 more for MongoEngine.
>
> -----Original Message-----
> From: flask@librelist.com [mailto:flask@librelist.com] On Behalf Of Marcus
> Carlsson
> Sent: Tuesday, October 30, 2012 7:48 AM
> To: flask@librelist.com
> Subject: Re: [flask] Flask, Mongo
>
> On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
>> I use with MongoEngine
>>
>> --
>> Gustavo Gawryszewski
>>
>>
>> On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
>>
>>>   As author of the Flask-Admin package, I want to add MongoDB backend. I
> can just rely on pymongo and scaffold interface based on input parameters
> (list of fields to display in list view, etc), but have few questions:
>>> 1. If you use MongoDB, do you use any kind of ORM? If yes, which
>>> one? (MongoAlchemy, MongoEngine, etc) 2. Do you use plain pymongo? If
> yes, do you just work with dictionaries or do some kind of schema mapping
> between your application and MongoDB records?
> +1 for MongoEngine
> --
> Marcus Carlsson
> http://xintron.se
>

Re: [flask] Flask, Mongo

From:
dorian i
Date:
2012-10-31 @ 20:49
https://github.com/SyrusAkbary/Flask-SuperAdmin this admin has mongoengine

On Tue, Oct 30, 2012 at 8:01 PM, Shamail Tayyab <me@shamail.in> wrote:

> Hi,
>
>     +1 MongoEngine too.
>
> Here is some concise usage of MongoEngine that will tell you why I mean it:
>
> class User (Document):    # say
>      username = StringField ()
>      _profile = ObjectIdField ()
>
>      @property
>      def getprofile (self):
>          return Profile.objects.get (self._profile)
>
>
> class Post (Document):
>      data = StringField ()
>      seostring = StringField ()
>      _comments = ListField (ObjectIdField())
>      _author = ObjectIdField ()
>
>      @property
>      def getcomments (self):
>          ordered = []
>          comments = Comment.objects.in_bulk (self._comments)  # returns
> a dict
>          for i in comments:
>              ordered.append (comments.get (i))
>
>          # Lets put authors in one go..
>          authors = map (lambda x: x._author, ordered)
>          author_objs = User.objects.in_bulk (authors)
>          for i in ordered:
>              i.author = author_objs.get (i._author)
>          return ordered
>
>
> class Comment (Document):
>      data = StringField ()
>      _author = ObjectIdField ()
>
>
> # Call like
> post = Post.objects.get (seostring = "fantastic_post")
>
> # And a render like this (in django's syntax, with flask I use Jade, so
> don't know much of the inbuilt templater)
> #
> # <p> {{ post.data }} </p>
> # <ul>
> # {% for c in post.getcomments %}
> #   <li> {{c.data}} - {{c.author}} </li>
> # {% endfor %}
> # </ul>
> #
> # Will use only 2 lookups.
>
> MongoEngine helps keep the abstraction of dirty code within; with
> pymongo, organization is not so oopic (unless you explicitly do it
> yourself by-hand).
>
> Hope that helps..
>
> Tx
>
> --
> Shamail Tayyab
>
> On 30/10/12 7:59 PM, Chris Higgins wrote:
> > I'm going to say +1 more for MongoEngine.
> >
> > -----Original Message-----
> > From: flask@librelist.com [mailto:flask@librelist.com] On Behalf Of
> Marcus
> > Carlsson
> > Sent: Tuesday, October 30, 2012 7:48 AM
> > To: flask@librelist.com
> > Subject: Re: [flask] Flask, Mongo
> >
> > On Tue, Oct 30, 2012 at 10:33:16AM -0200, Gustavo Gawryszewski wrote:
> >> I use with MongoEngine
> >>
> >> --
> >> Gustavo Gawryszewski
> >>
> >>
> >> On Tuesday, October 30, 2012 at 9:20 AM, Serge S. Koval wrote:
> >>
> >>>   As author of the Flask-Admin package, I want to add MongoDB backend.
> I
> > can just rely on pymongo and scaffold interface based on input parameters
> > (list of fields to display in list view, etc), but have few questions:
> >>> 1. If you use MongoDB, do you use any kind of ORM? If yes, which
> >>> one? (MongoAlchemy, MongoEngine, etc) 2. Do you use plain pymongo? If
> > yes, do you just work with dictionaries or do some kind of schema mapping
> > between your application and MongoDB records?
> > +1 for MongoEngine
> > --
> > Marcus Carlsson
> > http://xintron.se
> >
>
>

Re: [flask] Flask, Mongo

From:
Serge S. Koval
Date:
2012-10-31 @ 21:06
This is outdated fork of Flask-Admin with lots of missing features. But
yes, it has MongoEngine support.
Unfortunately, author declined to cooperate and I can't merge his
MongoEngine backend to Flask-Admin, as he changed internal structure as
well.

To summarize: looks like it is MongoEngine and raw pymongo. Most likely to
support both, with somewhat less features for pymongo.

Serge.

On Wed, Oct 31, 2012 at 10:49 PM, dorian i <dorian.hoxha@gmail.com> wrote:

> https://github.com/SyrusAkbary/Flask-SuperAdmin this admin has mongoengine

Re: [flask] Flask, Mongo

From:
dorian i
Date:
2012-10-31 @ 22:14
I'm using Mongoengine in my project. At a few places i use pymongo directly
for simple stuff. But what i would like was a tutorial of how you implement
ajax inline embededd documents and other fancy-forms stuff. Also for anyone
using mongoengine in their projects check flask_mongorest for rest api
using mongoengine.

On Wed, Oct 31, 2012 at 10:06 PM, Serge S. Koval <serge.koval@gmail.com>wrote:

> This is outdated fork of Flask-Admin with lots of missing features. But
> yes, it has MongoEngine support.
> Unfortunately, author declined to cooperate and I can't merge his
> MongoEngine backend to Flask-Admin, as he changed internal structure as
> well.
>
> To summarize: looks like it is MongoEngine and raw pymongo. Most likely to
> support both, with somewhat less features for pymongo.
>
> Serge.
>
>
> On Wed, Oct 31, 2012 at 10:49 PM, dorian i <dorian.hoxha@gmail.com> wrote:
>
>> https://github.com/SyrusAkbary/Flask-SuperAdmin this admin has
>> mongoengine
>
>

Re: [flask] Flask, Mongo

From:
Serge Émond
Date:
2012-10-30 @ 13:00
Hi,

Personnally, I use plain pymongo, often in conjonction with Schematics 
(used to be dictshield), depending on the type of document (e.g. 
incremental doc update logs are plain).  Tried other solutions, but always
come back to this.

On 2012-10-30, at 7:20, "Serge S. Koval" <serge.koval@gmail.com> wrote:

> Hi,
> 
>  As author of the Flask-Admin package, I want to add MongoDB backend. I 
can just rely on pymongo and scaffold interface based on input parameters 
(list of fields to display in list view, etc), but have few questions:
> 1. If you use MongoDB, do you use any kind of ORM? If yes, which one? 
(MongoAlchemy, MongoEngine, etc)
> 2. Do you use plain pymongo? If yes, do you just work with dictionaries 
or do some kind of schema mapping between your application and MongoDB 
records?
> 
> Thanks,
> Serge.