librelist archives

« back to archive

Flask + MongoEngine + MPTT?

Flask + MongoEngine + MPTT?

From:
Bruno Rocha
Date:
2013-07-13 @ 05:16
Hi,

I am developing a CMS powered by Flask and MongoEngine.
I have some experience building CMS in Django and in web2py, for both we
have the MPTT modules/plugins. Recently I used django-mptt to create the
channel/category structure for a CMS.

Now I am creating this one in Flask and MongoEngine and I need to know if
there is some MPTT blueprint/extension available?

I found this http://docs.mongodb.org/manual/tutorial/model-tree-structures/,
But nothing created on top of flask.ext and mongoengine.

If I cound not find it, maybe I will start to develop it to use on my
project.

Thanks.

---
Bruno Rocha
http://github.com/rochacbruno
http://rochacbruno.com.br
http://linkedin.com/in/rochacbruno

Re: Flask + MongoEngine + MPTT?

From:
Bruno Rocha
Date:
2013-07-13 @ 05:54
I guess I found a solution, and maybe there is no need for a module or
extension, taking a closer look to the mongo manual I realized that i can
use a mix of Parent references with matereialized paths

{
    "slug" : "node_slug",
    "parent": "parent_slug",
    "mpath": "root,parent_parent_slug,parent_slug,node_slug,"
    "long_slug": "/root/parent_parent_slug/parent_slug/node_slug"
}

So I will need index for "slug" and "parent", it seems to much but in that
way I can find the ancestors and children easily, also I can use the
"long_slug" field to query against an <path:long_slug> parameter.

I cant see a way to turn this approach in a flask.ext but I am open to
suggestions or advice from someone who is already using this with mongo.

Thanks

---
Bruno Rocha
http://github.com/rochacbruno
http://rochacbruno.com.br
http://linkedin.com/in/rochacbruno


On Sat, Jul 13, 2013 at 2:16 AM, Bruno Rocha <rochacbruno@gmail.com> wrote:

> Hi,
>
> I am developing a CMS powered by Flask and MongoEngine.
> I have some experience building CMS in Django and in web2py, for both we
> have the MPTT modules/plugins. Recently I used django-mptt to create the
> channel/category structure for a CMS.
>
> Now I am creating this one in Flask and MongoEngine and I need to know if
> there is some MPTT blueprint/extension available?
>
> I found this
> http://docs.mongodb.org/manual/tutorial/model-tree-structures/, But
> nothing created on top of flask.ext and mongoengine.
>
> If I cound not find it, maybe I will start to develop it to use on my
> project.
>
> Thanks.
>
> ---
> Bruno Rocha
> http://github.com/rochacbruno
> http://rochacbruno.com.br
> http://linkedin.com/in/rochacbruno
>
>
>