librelist archives

« back to archive

Larger Applications, I'm trying to achieve this directory structure

Larger Applications, I'm trying to achieve this directory structure

From:
Ryan Cole
Date:
2010-09-02 @ 00:29
Hi all,

I'm trying to achieve the directory structure mentioned very briefly at the
end of the packages documentation. The direct permalink is here:
http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources

I'm a little confused as to what goes where. I understand the section prior
to the Modules and Resources section, but I feel like the documentation
makes a quick jump to the section that I'm interested in.

Would I still create my Flask "app" object in the outter-most __init__.py
file, and then use app.register_module from there? And then, in the
__init__.py files inside each Module's directory create the Module objects?
This would leave the views.py file empty, which confuses me a little. Would
I instead leave __init__.py in each Module's directory empty, and create the
Module objects inside the view.py file, then?

I guess I'm just a little confused. Perhaps does anyone have a complete but
simple example on github, or something?

Thank you,
Ryan

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-02 @ 06:57
https://bitbucket.org/danjac/newsmeme/
http://github.com/mitsuhiko/flask/tree/website

On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com> wrote:
> Hi all,
> I'm trying to achieve the directory structure mentioned very briefly at the
> end of the packages documentation. The direct permalink is
> here: http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
> I'm a little confused as to what goes where. I understand the section prior
> to the Modules and Resources section, but I feel like the documentation
> makes a quick jump to the section that I'm interested in.
> Would I still create my Flask "app" object in the outter-most __init__.py
> file, and then use app.register_module from there? And then, in the
> __init__.py files inside each Module's directory create the Module objects?
> This would leave the views.py file empty, which confuses me a little. Would
> I instead leave __init__.py in each Module's directory empty, and create the
> Module objects inside the view.py file, then?
> I guess I'm just a little confused. Perhaps does anyone have a complete but
> simple example on github, or something?
> Thank you,
> Ryan

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
bruce bushby
Date:
2010-09-02 @ 09:07
could not decode message

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Italo Maia
Date:
2010-09-03 @ 07:47
My pleasure, bruce! ö/

Anton, the skeleton project you posted does not work for createdb, right?
Take a look at the code bruce posted. It has a workaround for that. It would
be nice to have a manage.py in your skeleton too, that could accept some
commands like runserver, createdb and stuff like that. What you think? If
the functions were there, someone could easely use flask-script extension
with them.

2010/9/2 bruce bushby <bruce.bushby@googlemail.com>

>
> A while back I encountered the same problem and being new to python didn't
> help either.
>
> I posted a message to the list asking to hire a flask developer to code me
> some small examples which I could follow, Italo Maia offered his services
> and I must say the examples have helped me
> understand a lot more. The key was to have a very simple website that
> starts of in the "small format" showing the changes on the way to the "big
> layout"
>
> Perhaps they can be added to the examples folder...which is looking a
> little bare.
>
> I've attached them in hope they'll help others, I did purchase them so I
> assume I have the right to hand them out. I've got another example which has
> some css but I would need to remove my "branding" first. Thanks Italo for
> coding them!
>
>
> Bruce
>
>
>
>
> On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <danjac354@gmail.com> wrote:
>
>> https://bitbucket.org/danjac/newsmeme/
>> http://github.com/mitsuhiko/flask/tree/website
>>
>> On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com> wrote:
>> > Hi all,
>> > I'm trying to achieve the directory structure mentioned very briefly at
>> the
>> > end of the packages documentation. The direct permalink is
>> > here:
>> http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>> > I'm a little confused as to what goes where. I understand the section
>> prior
>> > to the Modules and Resources section, but I feel like the documentation
>> > makes a quick jump to the section that I'm interested in.
>> > Would I still create my Flask "app" object in the outter-most
>> __init__.py
>> > file, and then use app.register_module from there? And then, in the
>> > __init__.py files inside each Module's directory create the Module
>> objects?
>> > This would leave the views.py file empty, which confuses me a little.
>> Would
>> > I instead leave __init__.py in each Module's directory empty, and create
>> the
>> > Module objects inside the view.py file, then?
>> > I guess I'm just a little confused. Perhaps does anyone have a complete
>> but
>> > simple example on github, or something?
>> > Thank you,
>> > Ryan
>>
>
>


-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-03 @ 08:51
Hi Italo,

May be a small bug.
Currently he loads the views but not the models.py

We can use a python file for the configuration.

The manage could use this file for the creation of the database and for 
the loading of the modules.

Regards,

Stéphane

On 09/03/2010 09:47 AM, Italo Maia wrote:
> My pleasure, bruce! ö/
> 
> Anton, the skeleton project you posted does not work for createdb,
> right? Take a look at the code bruce posted. It has a workaround for
> that. It would be nice to have a manage.py in your skeleton too, that
> could accept some commands like runserver, createdb and stuff like that.
> What you think? If the functions were there, someone could easely use
> flask-script extension with them.
> 
> 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
> <mailto:bruce.bushby@googlemail.com>>
> 
> 
>     A while back I encountered the same problem and being new to python
>     didn't help either.
> 
>     I posted a message to the list asking to hire a flask developer to
>     code me some small examples which I could follow, Italo Maia offered
>     his services and I must say the examples have helped me
>     understand a lot more. The key was to have a very simple website
>     that starts of in the "small format" showing the changes on the way
>     to the "big layout"
> 
>     Perhaps they can be added to the examples folder...which is looking
>     a little bare.
> 
>     I've attached them in hope they'll help others, I did purchase them
>     so I assume I have the right to hand them out. I've got another
>     example which has some css but I would need to remove my "branding"
>     first. Thanks Italo for coding them!
> 
> 
>     Bruce
> 
> 
> 
> 
>     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <danjac354@gmail.com
>     <mailto:danjac354@gmail.com>> wrote:
> 
>         https://bitbucket.org/danjac/newsmeme/
>         http://github.com/mitsuhiko/flask/tree/website
> 
>         On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com
>         <mailto:betawarz@gmail.com>> wrote:
>         > Hi all,
>         > I'm trying to achieve the directory structure mentioned very
>         briefly at the
>         > end of the packages documentation. The direct permalink is
>         >
>         here: 
http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>         > I'm a little confused as to what goes where. I understand the
>         section prior
>         > to the Modules and Resources section, but I feel like the
>         documentation
>         > makes a quick jump to the section that I'm interested in.
>         > Would I still create my Flask "app" object in the outter-most
>         __init__.py
>         > file, and then use app.register_module from there? And then,
>         in the
>         > __init__.py files inside each Module's directory create the
>         Module objects?
>         > This would leave the views.py file empty, which confuses me a
>         little. Would
>         > I instead leave __init__.py in each Module's directory empty,
>         and create the
>         > Module objects inside the view.py file, then?
>         > I guess I'm just a little confused. Perhaps does anyone have a
>         complete but
>         > simple example on github, or something?
>         > Thank you,
>         > Ryan
> 
> 
> 
> 
> 
> -- 
> "A arrogância é a arma dos fracos."
> 
> ===========================
> Italo Moreira Campelo Maia
> Graduado em Ciência da Computação - UECE
> Desenvolvedor WEB e Desktop (Java, Python, Lua)
> Coordenador do Pug-CE
> -----------------------------------------------------
> http://www.italomaia.com/
> http://twitter.com/italomaia/
> http://eusouolobomau.blogspot.com/
> -----------------------------------------------------
> turtle linux 910 - http://tiny.cc/blogturtle910
> ===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Italo Maia
Date:
2010-09-03 @ 09:09
I'll be forking the skeleton here and add some stuff i find cool. Tell me
what you think. = ]

2010/9/3 Stephane Wirtel <stephane@wirtel.be>

> Hi Italo,
>
> May be a small bug.
> Currently he loads the views but not the models.py
>
> We can use a python file for the configuration.
>
> The manage could use this file for the creation of the database and for the
> loading of the modules.
>
> Regards,
>
> Stéphane
>
> On 09/03/2010 09:47 AM, Italo Maia wrote:
> > My pleasure, bruce! ö/
> >
> > Anton, the skeleton project you posted does not work for createdb,
> > right? Take a look at the code bruce posted. It has a workaround for
> > that. It would be nice to have a manage.py in your skeleton too, that
> > could accept some commands like runserver, createdb and stuff like that.
> > What you think? If the functions were there, someone could easely use
> > flask-script extension with them.
> >
> > 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
> > <mailto:bruce.bushby@googlemail.com>>
> >
> >
> >     A while back I encountered the same problem and being new to python
> >     didn't help either.
> >
> >     I posted a message to the list asking to hire a flask developer to
> >     code me some small examples which I could follow, Italo Maia offered
> >     his services and I must say the examples have helped me
> >     understand a lot more. The key was to have a very simple website
> >     that starts of in the "small format" showing the changes on the way
> >     to the "big layout"
> >
> >     Perhaps they can be added to the examples folder...which is looking
> >     a little bare.
> >
> >     I've attached them in hope they'll help others, I did purchase them
> >     so I assume I have the right to hand them out. I've got another
> >     example which has some css but I would need to remove my "branding"
> >     first. Thanks Italo for coding them!
> >
> >
> >     Bruce
> >
> >
> >
> >
> >     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <danjac354@gmail.com
> >     <mailto:danjac354@gmail.com>> wrote:
> >
> >         https://bitbucket.org/danjac/newsmeme/
> >         http://github.com/mitsuhiko/flask/tree/website
> >
> >         On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com
> >         <mailto:betawarz@gmail.com>> wrote:
> >         > Hi all,
> >         > I'm trying to achieve the directory structure mentioned very
> >         briefly at the
> >         > end of the packages documentation. The direct permalink is
> >         >
> >         here:
> http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
> >         > I'm a little confused as to what goes where. I understand the
> >         section prior
> >         > to the Modules and Resources section, but I feel like the
> >         documentation
> >         > makes a quick jump to the section that I'm interested in.
> >         > Would I still create my Flask "app" object in the outter-most
> >         __init__.py
> >         > file, and then use app.register_module from there? And then,
> >         in the
> >         > __init__.py files inside each Module's directory create the
> >         Module objects?
> >         > This would leave the views.py file empty, which confuses me a
> >         little. Would
> >         > I instead leave __init__.py in each Module's directory empty,
> >         and create the
> >         > Module objects inside the view.py file, then?
> >         > I guess I'm just a little confused. Perhaps does anyone have a
> >         complete but
> >         > simple example on github, or something?
> >         > Thank you,
> >         > Ryan
> >
> >
> >
> >
> >
> > --
> > "A arrogância é a arma dos fracos."
> >
> > ===========================
> > Italo Moreira Campelo Maia
> > Graduado em Ciência da Computação - UECE
> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
> > Coordenador do Pug-CE
> > -----------------------------------------------------
> > http://www.italomaia.com/
> > http://twitter.com/italomaia/
> > http://eusouolobomau.blogspot.com/
> > -----------------------------------------------------
> > turtle linux 910 - http://tiny.cc/blogturtle910
> > ===========================
>
>


-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-03 @ 09:28
Ok, Show me the result and may be, I will add something if I have time.

Regards,
On 09/03/2010 11:09 AM, Italo Maia wrote:
> I'll be forking the skeleton here and add some stuff i find cool. Tell
> me what you think. = ]
> 
> 2010/9/3 Stephane Wirtel <stephane@wirtel.be <mailto:stephane@wirtel.be>>
> 
>     Hi Italo,
> 
>     May be a small bug.
>     Currently he loads the views but not the models.py
> 
>     We can use a python file for the configuration.
> 
>     The manage could use this file for the creation of the database and
>     for the loading of the modules.
> 
>     Regards,
> 
>     Stéphane
> 
>     On 09/03/2010 09:47 AM, Italo Maia wrote:
>     > My pleasure, bruce! ö/
>     >
>     > Anton, the skeleton project you posted does not work for createdb,
>     > right? Take a look at the code bruce posted. It has a workaround for
>     > that. It would be nice to have a manage.py in your skeleton too, that
>     > could accept some commands like runserver, createdb and stuff like
>     that.
>     > What you think? If the functions were there, someone could easely use
>     > flask-script extension with them.
>     >
>     > 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
>     <mailto:bruce.bushby@googlemail.com>
>     > <mailto:bruce.bushby@googlemail.com
>     <mailto:bruce.bushby@googlemail.com>>>
>     >
>     >
>     >     A while back I encountered the same problem and being new to
>     python
>     >     didn't help either.
>     >
>     >     I posted a message to the list asking to hire a flask developer to
>     >     code me some small examples which I could follow, Italo Maia
>     offered
>     >     his services and I must say the examples have helped me
>     >     understand a lot more. The key was to have a very simple website
>     >     that starts of in the "small format" showing the changes on
>     the way
>     >     to the "big layout"
>     >
>     >     Perhaps they can be added to the examples folder...which is
>     looking
>     >     a little bare.
>     >
>     >     I've attached them in hope they'll help others, I did purchase
>     them
>     >     so I assume I have the right to hand them out. I've got another
>     >     example which has some css but I would need to remove my
>     "branding"
>     >     first. Thanks Italo for coding them!
>     >
>     >
>     >     Bruce
>     >
>     >
>     >
>     >
>     >     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <danjac354@gmail.com
>     <mailto:danjac354@gmail.com>
>     >     <mailto:danjac354@gmail.com <mailto:danjac354@gmail.com>>> wrote:
>     >
>     >         https://bitbucket.org/danjac/newsmeme/
>     >         http://github.com/mitsuhiko/flask/tree/website
>     >
>     >         On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com
>     <mailto:betawarz@gmail.com>
>     >         <mailto:betawarz@gmail.com <mailto:betawarz@gmail.com>>>
>     wrote:
>     >         > Hi all,
>     >         > I'm trying to achieve the directory structure mentioned very
>     >         briefly at the
>     >         > end of the packages documentation. The direct permalink is
>     >         >
>     >         here:
>     http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>     >         > I'm a little confused as to what goes where. I
>     understand the
>     >         section prior
>     >         > to the Modules and Resources section, but I feel like the
>     >         documentation
>     >         > makes a quick jump to the section that I'm interested in.
>     >         > Would I still create my Flask "app" object in the
>     outter-most
>     >         __init__.py
>     >         > file, and then use app.register_module from there? And then,
>     >         in the
>     >         > __init__.py files inside each Module's directory create the
>     >         Module objects?
>     >         > This would leave the views.py file empty, which confuses
>     me a
>     >         little. Would
>     >         > I instead leave __init__.py in each Module's directory
>     empty,
>     >         and create the
>     >         > Module objects inside the view.py file, then?
>     >         > I guess I'm just a little confused. Perhaps does anyone
>     have a
>     >         complete but
>     >         > simple example on github, or something?
>     >         > Thank you,
>     >         > Ryan
>     >
>     >
>     >
>     >
>     >
>     > --
>     > "A arrogância é a arma dos fracos."
>     >
>     > ===========================
>     > Italo Moreira Campelo Maia
>     > Graduado em Ciência da Computação - UECE
>     > Desenvolvedor WEB e Desktop (Java, Python, Lua)
>     > Coordenador do Pug-CE
>     > -----------------------------------------------------
>     > http://www.italomaia.com/
>     > http://twitter.com/italomaia/
>     > http://eusouolobomau.blogspot.com/
>     > -----------------------------------------------------
>     > turtle linux 910 - http://tiny.cc/blogturtle910
>     > ===========================
> 
> 
> 
> 
> -- 
> "A arrogância é a arma dos fracos."
> 
> ===========================
> Italo Moreira Campelo Maia
> Graduado em Ciência da Computação - UECE
> Desenvolvedor WEB e Desktop (Java, Python, Lua)
> Coordenador do Pug-CE
> -----------------------------------------------------
> http://www.italomaia.com/
> http://twitter.com/italomaia/
> http://eusouolobomau.blogspot.com/
> -----------------------------------------------------
> turtle linux 910 - http://tiny.cc/blogturtle910
> ===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Italo Maia
Date:
2010-09-03 @ 10:01
There you go! http://github.com/italomaia/flask looks nice. Could be more
"modular" maybe. When i saw "admin" in apps, almost drop a tear here. Flask
soooo need a admin app.

2010/9/3 Stephane Wirtel <stephane@wirtel.be>

> Ok, Show me the result and may be, I will add something if I have time.
>
> Regards,
> On 09/03/2010 11:09 AM, Italo Maia wrote:
> > I'll be forking the skeleton here and add some stuff i find cool. Tell
> > me what you think. = ]
> >
> > 2010/9/3 Stephane Wirtel <stephane@wirtel.be <mailto:stephane@wirtel.be
> >>
> >
> >     Hi Italo,
> >
> >     May be a small bug.
> >     Currently he loads the views but not the models.py
> >
> >     We can use a python file for the configuration.
> >
> >     The manage could use this file for the creation of the database and
> >     for the loading of the modules.
> >
> >     Regards,
> >
> >     Stéphane
> >
> >     On 09/03/2010 09:47 AM, Italo Maia wrote:
> >     > My pleasure, bruce! ö/
> >     >
> >     > Anton, the skeleton project you posted does not work for createdb,
> >     > right? Take a look at the code bruce posted. It has a workaround
> for
> >     > that. It would be nice to have a manage.py in your skeleton too,
> that
> >     > could accept some commands like runserver, createdb and stuff like
> >     that.
> >     > What you think? If the functions were there, someone could easely
> use
> >     > flask-script extension with them.
> >     >
> >     > 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
> >     <mailto:bruce.bushby@googlemail.com>
> >     > <mailto:bruce.bushby@googlemail.com
> >     <mailto:bruce.bushby@googlemail.com>>>
> >     >
> >     >
> >     >     A while back I encountered the same problem and being new to
> >     python
> >     >     didn't help either.
> >     >
> >     >     I posted a message to the list asking to hire a flask developer
> to
> >     >     code me some small examples which I could follow, Italo Maia
> >     offered
> >     >     his services and I must say the examples have helped me
> >     >     understand a lot more. The key was to have a very simple
> website
> >     >     that starts of in the "small format" showing the changes on
> >     the way
> >     >     to the "big layout"
> >     >
> >     >     Perhaps they can be added to the examples folder...which is
> >     looking
> >     >     a little bare.
> >     >
> >     >     I've attached them in hope they'll help others, I did purchase
> >     them
> >     >     so I assume I have the right to hand them out. I've got another
> >     >     example which has some css but I would need to remove my
> >     "branding"
> >     >     first. Thanks Italo for coding them!
> >     >
> >     >
> >     >     Bruce
> >     >
> >     >
> >     >
> >     >
> >     >     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <danjac354@gmail.com
> >     <mailto:danjac354@gmail.com>
> >     >     <mailto:danjac354@gmail.com <mailto:danjac354@gmail.com>>>
> wrote:
> >     >
> >     >         https://bitbucket.org/danjac/newsmeme/
> >     >         http://github.com/mitsuhiko/flask/tree/website
> >     >
> >     >         On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com
> >     <mailto:betawarz@gmail.com>
> >     >         <mailto:betawarz@gmail.com <mailto:betawarz@gmail.com>>>
> >     wrote:
> >     >         > Hi all,
> >     >         > I'm trying to achieve the directory structure mentioned
> very
> >     >         briefly at the
> >     >         > end of the packages documentation. The direct permalink
> is
> >     >         >
> >     >         here:
> >     http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
> >     >         > I'm a little confused as to what goes where. I
> >     understand the
> >     >         section prior
> >     >         > to the Modules and Resources section, but I feel like the
> >     >         documentation
> >     >         > makes a quick jump to the section that I'm interested in.
> >     >         > Would I still create my Flask "app" object in the
> >     outter-most
> >     >         __init__.py
> >     >         > file, and then use app.register_module from there? And
> then,
> >     >         in the
> >     >         > __init__.py files inside each Module's directory create
> the
> >     >         Module objects?
> >     >         > This would leave the views.py file empty, which confuses
> >     me a
> >     >         little. Would
> >     >         > I instead leave __init__.py in each Module's directory
> >     empty,
> >     >         and create the
> >     >         > Module objects inside the view.py file, then?
> >     >         > I guess I'm just a little confused. Perhaps does anyone
> >     have a
> >     >         complete but
> >     >         > simple example on github, or something?
> >     >         > Thank you,
> >     >         > Ryan
> >     >
> >     >
> >     >
> >     >
> >     >
> >     > --
> >     > "A arrogância é a arma dos fracos."
> >     >
> >     > ===========================
> >     > Italo Moreira Campelo Maia
> >     > Graduado em Ciência da Computação - UECE
> >     > Desenvolvedor WEB e Desktop (Java, Python, Lua)
> >     > Coordenador do Pug-CE
> >     > -----------------------------------------------------
> >     > http://www.italomaia.com/
> >     > http://twitter.com/italomaia/
> >     > http://eusouolobomau.blogspot.com/
> >     > -----------------------------------------------------
> >     > turtle linux 910 - http://tiny.cc/blogturtle910
> >     > ===========================
> >
> >
> >
> >
> > --
> > "A arrogância é a arma dos fracos."
> >
> > ===========================
> > Italo Moreira Campelo Maia
> > Graduado em Ciência da Computação - UECE
> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
> > Coordenador do Pug-CE
> > -----------------------------------------------------
> > http://www.italomaia.com/
> > http://twitter.com/italomaia/
> > http://eusouolobomau.blogspot.com/
> > -----------------------------------------------------
> > turtle linux 910 - http://tiny.cc/blogturtle910
> > ===========================
>
>


-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-03 @ 10:07
The problem with an admin app is that you need to be able to handle
different backends. Django comes with a prepackaged ORM,
authentication etc, which makes it a lot easier to have a ready admin
app; the problem with that is you lose the flexibility.

It *might* be possible to have a generic framework on top of Flask for
building admin apps, but the time taken to configure all the various
options (CouchDB ? SQLAlchemy ? OpenID ? etc etc) might outweigh any
real benefit.

Most frameworks seem to manage fine without an admin app, as in
general this is something that is very project-specific. That said
it's probably THE selling point for Django (some might even say the
ONLY selling point ;-))

On 3 September 2010 11:01, Italo Maia <italo.maia@gmail.com> wrote:
> There you go! http://github.com/italomaia/flask looks nice. Could be more
> "modular" maybe. When i saw "admin" in apps, almost drop a tear here. Flask
> soooo need a admin app.
>
> 2010/9/3 Stephane Wirtel <stephane@wirtel.be>
>>
>> Ok, Show me the result and may be, I will add something if I have time.
>>
>> Regards,
>> On 09/03/2010 11:09 AM, Italo Maia wrote:
>> > I'll be forking the skeleton here and add some stuff i find cool. Tell
>> > me what you think. = ]
>> >
>> > 2010/9/3 Stephane Wirtel <stephane@wirtel.be
>> > <mailto:stephane@wirtel.be>>
>> >
>> >     Hi Italo,
>> >
>> >     May be a small bug.
>> >     Currently he loads the views but not the models.py
>> >
>> >     We can use a python file for the configuration.
>> >
>> >     The manage could use this file for the creation of the database and
>> >     for the loading of the modules.
>> >
>> >     Regards,
>> >
>> >     Stéphane
>> >
>> >     On 09/03/2010 09:47 AM, Italo Maia wrote:
>> >     > My pleasure, bruce! ö/
>> >     >
>> >     > Anton, the skeleton project you posted does not work for createdb,
>> >     > right? Take a look at the code bruce posted. It has a workaround
>> > for
>> >     > that. It would be nice to have a manage.py in your skeleton too,
>> > that
>> >     > could accept some commands like runserver, createdb and stuff like
>> >     that.
>> >     > What you think? If the functions were there, someone could easely
>> > use
>> >     > flask-script extension with them.
>> >     >
>> >     > 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
>> >     <mailto:bruce.bushby@googlemail.com>
>> >     > <mailto:bruce.bushby@googlemail.com
>> >     <mailto:bruce.bushby@googlemail.com>>>
>> >     >
>> >     >
>> >     >     A while back I encountered the same problem and being new to
>> >     python
>> >     >     didn't help either.
>> >     >
>> >     >     I posted a message to the list asking to hire a flask
>> > developer to
>> >     >     code me some small examples which I could follow, Italo Maia
>> >     offered
>> >     >     his services and I must say the examples have helped me
>> >     >     understand a lot more. The key was to have a very simple
>> > website
>> >     >     that starts of in the "small format" showing the changes on
>> >     the way
>> >     >     to the "big layout"
>> >     >
>> >     >     Perhaps they can be added to the examples folder...which is
>> >     looking
>> >     >     a little bare.
>> >     >
>> >     >     I've attached them in hope they'll help others, I did purchase
>> >     them
>> >     >     so I assume I have the right to hand them out. I've got
>> > another
>> >     >     example which has some css but I would need to remove my
>> >     "branding"
>> >     >     first. Thanks Italo for coding them!
>> >     >
>> >     >
>> >     >     Bruce
>> >     >
>> >     >
>> >     >
>> >     >
>> >     >     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <danjac354@gmail.com
>> >     <mailto:danjac354@gmail.com>
>> >     >     <mailto:danjac354@gmail.com <mailto:danjac354@gmail.com>>>
>> > wrote:
>> >     >
>> >     >         https://bitbucket.org/danjac/newsmeme/
>> >     >         http://github.com/mitsuhiko/flask/tree/website
>> >     >
>> >     >         On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com
>> >     <mailto:betawarz@gmail.com>
>> >     >         <mailto:betawarz@gmail.com <mailto:betawarz@gmail.com>>>
>> >     wrote:
>> >     >         > Hi all,
>> >     >         > I'm trying to achieve the directory structure mentioned
>> > very
>> >     >         briefly at the
>> >     >         > end of the packages documentation. The direct permalink
>> > is
>> >     >         >
>> >     >         here:
>> >     http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>> >     >         > I'm a little confused as to what goes where. I
>> >     understand the
>> >     >         section prior
>> >     >         > to the Modules and Resources section, but I feel like
>> > the
>> >     >         documentation
>> >     >         > makes a quick jump to the section that I'm interested
>> > in.
>> >     >         > Would I still create my Flask "app" object in the
>> >     outter-most
>> >     >         __init__.py
>> >     >         > file, and then use app.register_module from there? And
>> > then,
>> >     >         in the
>> >     >         > __init__.py files inside each Module's directory create
>> > the
>> >     >         Module objects?
>> >     >         > This would leave the views.py file empty, which confuses
>> >     me a
>> >     >         little. Would
>> >     >         > I instead leave __init__.py in each Module's directory
>> >     empty,
>> >     >         and create the
>> >     >         > Module objects inside the view.py file, then?
>> >     >         > I guess I'm just a little confused. Perhaps does anyone
>> >     have a
>> >     >         complete but
>> >     >         > simple example on github, or something?
>> >     >         > Thank you,
>> >     >         > Ryan
>> >     >
>> >     >
>> >     >
>> >     >
>> >     >
>> >     > --
>> >     > "A arrogância é a arma dos fracos."
>> >     >
>> >     > ===========================
>> >     > Italo Moreira Campelo Maia
>> >     > Graduado em Ciência da Computação - UECE
>> >     > Desenvolvedor WEB e Desktop (Java, Python, Lua)
>> >     > Coordenador do Pug-CE
>> >     > -----------------------------------------------------
>> >     > http://www.italomaia.com/
>> >     > http://twitter.com/italomaia/
>> >     > http://eusouolobomau.blogspot.com/
>> >     > -----------------------------------------------------
>> >     > turtle linux 910 - http://tiny.cc/blogturtle910
>> >     > ===========================
>> >
>> >
>> >
>> >
>> > --
>> > "A arrogância é a arma dos fracos."
>> >
>> > ===========================
>> > Italo Moreira Campelo Maia
>> > Graduado em Ciência da Computação - UECE
>> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
>> > Coordenador do Pug-CE
>> > -----------------------------------------------------
>> > http://www.italomaia.com/
>> > http://twitter.com/italomaia/
>> > http://eusouolobomau.blogspot.com/
>> > -----------------------------------------------------
>> > turtle linux 910 - http://tiny.cc/blogturtle910
>> > ===========================
>>
>
>
>
> --
> "A arrogância é a arma dos fracos."
>
> ===========================
> Italo Moreira Campelo Maia
> Graduado em Ciência da Computação - UECE
> Desenvolvedor WEB e Desktop (Java, Python, Lua)
> Coordenador do Pug-CE
> -----------------------------------------------------
> http://www.italomaia.com/
> http://twitter.com/italomaia/
> http://eusouolobomau.blogspot.com/
> -----------------------------------------------------
> turtle linux 910 - http://tiny.cc/blogturtle910
> ===========================
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Italo Maia
Date:
2010-09-03 @ 15:19
Totally agree. Something not bundled would be indeed best. Maybe a
repository for flask modules/apps would be nice. So, someone could just
build his project with this parts, like a admin for mongo or SA (or some
other stuff), a blog, stuff and stuff. Basically, this would mean no bundled
"evil coupling" stuff and apps could still look powerful.

Aaaaanyway, my 2 cents in the current discussion: i find flask modules a
really nice approach. Maybe, there could be some kind of filter one could
attach to a module instance before registering it to make the behavior
Davide said to work. Making a framework over flask could work and all, but
that would just create another turbogears. Can't see much advantage to that.


My humble me really thinks keeping the "Lego way of life" in flask could
really show itself advantegeous, without all the django coupling.

ps: Lot of people are facing Ryan's problem and running for pylons to work
around that, but, if you take a close look, flask is much more of a piece of
art than pylons. I think there is tremendous space to grow in this matter.

2010/9/3 Dan Jacob <danjac354@gmail.com>

> The problem with an admin app is that you need to be able to handle
> different backends. Django comes with a prepackaged ORM,
> authentication etc, which makes it a lot easier to have a ready admin
> app; the problem with that is you lose the flexibility.
>
> It *might* be possible to have a generic framework on top of Flask for
> building admin apps, but the time taken to configure all the various
> options (CouchDB ? SQLAlchemy ? OpenID ? etc etc) might outweigh any
> real benefit.
>
> Most frameworks seem to manage fine without an admin app, as in
> general this is something that is very project-specific. That said
> it's probably THE selling point for Django (some might even say the
> ONLY selling point ;-))
>
> On 3 September 2010 11:01, Italo Maia <italo.maia@gmail.com> wrote:
> > There you go! http://github.com/italomaia/flask looks nice. Could be
> more
> > "modular" maybe. When i saw "admin" in apps, almost drop a tear here.
> Flask
> > soooo need a admin app.
> >
> > 2010/9/3 Stephane Wirtel <stephane@wirtel.be>
> >>
> >> Ok, Show me the result and may be, I will add something if I have time.
> >>
> >> Regards,
> >> On 09/03/2010 11:09 AM, Italo Maia wrote:
> >> > I'll be forking the skeleton here and add some stuff i find cool. Tell
> >> > me what you think. = ]
> >> >
> >> > 2010/9/3 Stephane Wirtel <stephane@wirtel.be
> >> > <mailto:stephane@wirtel.be>>
> >> >
> >> >     Hi Italo,
> >> >
> >> >     May be a small bug.
> >> >     Currently he loads the views but not the models.py
> >> >
> >> >     We can use a python file for the configuration.
> >> >
> >> >     The manage could use this file for the creation of the database
> and
> >> >     for the loading of the modules.
> >> >
> >> >     Regards,
> >> >
> >> >     Stéphane
> >> >
> >> >     On 09/03/2010 09:47 AM, Italo Maia wrote:
> >> >     > My pleasure, bruce! ö/
> >> >     >
> >> >     > Anton, the skeleton project you posted does not work for
> createdb,
> >> >     > right? Take a look at the code bruce posted. It has a workaround
> >> > for
> >> >     > that. It would be nice to have a manage.py in your skeleton too,
> >> > that
> >> >     > could accept some commands like runserver, createdb and stuff
> like
> >> >     that.
> >> >     > What you think? If the functions were there, someone could
> easely
> >> > use
> >> >     > flask-script extension with them.
> >> >     >
> >> >     > 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
> >> >     <mailto:bruce.bushby@googlemail.com>
> >> >     > <mailto:bruce.bushby@googlemail.com
> >> >     <mailto:bruce.bushby@googlemail.com>>>
> >> >     >
> >> >     >
> >> >     >     A while back I encountered the same problem and being new to
> >> >     python
> >> >     >     didn't help either.
> >> >     >
> >> >     >     I posted a message to the list asking to hire a flask
> >> > developer to
> >> >     >     code me some small examples which I could follow, Italo Maia
> >> >     offered
> >> >     >     his services and I must say the examples have helped me
> >> >     >     understand a lot more. The key was to have a very simple
> >> > website
> >> >     >     that starts of in the "small format" showing the changes on
> >> >     the way
> >> >     >     to the "big layout"
> >> >     >
> >> >     >     Perhaps they can be added to the examples folder...which is
> >> >     looking
> >> >     >     a little bare.
> >> >     >
> >> >     >     I've attached them in hope they'll help others, I did
> purchase
> >> >     them
> >> >     >     so I assume I have the right to hand them out. I've got
> >> > another
> >> >     >     example which has some css but I would need to remove my
> >> >     "branding"
> >> >     >     first. Thanks Italo for coding them!
> >> >     >
> >> >     >
> >> >     >     Bruce
> >> >     >
> >> >     >
> >> >     >
> >> >     >
> >> >     >     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob <
> danjac354@gmail.com
> >> >     <mailto:danjac354@gmail.com>
> >> >     >     <mailto:danjac354@gmail.com <mailto:danjac354@gmail.com>>>
> >> > wrote:
> >> >     >
> >> >     >         https://bitbucket.org/danjac/newsmeme/
> >> >     >         http://github.com/mitsuhiko/flask/tree/website
> >> >     >
> >> >     >         On 2 September 2010 01:29, Ryan Cole <
> betawarz@gmail.com
> >> >     <mailto:betawarz@gmail.com>
> >> >     >         <mailto:betawarz@gmail.com <mailto:betawarz@gmail.com
> >>>
> >> >     wrote:
> >> >     >         > Hi all,
> >> >     >         > I'm trying to achieve the directory structure
> mentioned
> >> > very
> >> >     >         briefly at the
> >> >     >         > end of the packages documentation. The direct
> permalink
> >> > is
> >> >     >         >
> >> >     >         here:
> >> >
> http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
> >> >     >         > I'm a little confused as to what goes where. I
> >> >     understand the
> >> >     >         section prior
> >> >     >         > to the Modules and Resources section, but I feel like
> >> > the
> >> >     >         documentation
> >> >     >         > makes a quick jump to the section that I'm interested
> >> > in.
> >> >     >         > Would I still create my Flask "app" object in the
> >> >     outter-most
> >> >     >         __init__.py
> >> >     >         > file, and then use app.register_module from there? And
> >> > then,
> >> >     >         in the
> >> >     >         > __init__.py files inside each Module's directory
> create
> >> > the
> >> >     >         Module objects?
> >> >     >         > This would leave the views.py file empty, which
> confuses
> >> >     me a
> >> >     >         little. Would
> >> >     >         > I instead leave __init__.py in each Module's directory
> >> >     empty,
> >> >     >         and create the
> >> >     >         > Module objects inside the view.py file, then?
> >> >     >         > I guess I'm just a little confused. Perhaps does
> anyone
> >> >     have a
> >> >     >         complete but
> >> >     >         > simple example on github, or something?
> >> >     >         > Thank you,
> >> >     >         > Ryan
> >> >     >
> >> >     >
> >> >     >
> >> >     >
> >> >     >
> >> >     > --
> >> >     > "A arrogância é a arma dos fracos."
> >> >     >
> >> >     > ===========================
> >> >     > Italo Moreira Campelo Maia
> >> >     > Graduado em Ciência da Computação - UECE
> >> >     > Desenvolvedor WEB e Desktop (Java, Python, Lua)
> >> >     > Coordenador do Pug-CE
> >> >     > -----------------------------------------------------
> >> >     > http://www.italomaia.com/
> >> >     > http://twitter.com/italomaia/
> >> >     > http://eusouolobomau.blogspot.com/
> >> >     > -----------------------------------------------------
> >> >     > turtle linux 910 - http://tiny.cc/blogturtle910
> >> >     > ===========================
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > "A arrogância é a arma dos fracos."
> >> >
> >> > ===========================
> >> > Italo Moreira Campelo Maia
> >> > Graduado em Ciência da Computação - UECE
> >> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
> >> > Coordenador do Pug-CE
> >> > -----------------------------------------------------
> >> > http://www.italomaia.com/
> >> > http://twitter.com/italomaia/
> >> > http://eusouolobomau.blogspot.com/
> >> > -----------------------------------------------------
> >> > turtle linux 910 - http://tiny.cc/blogturtle910
> >> > ===========================
> >>
> >
> >
> >
> > --
> > "A arrogância é a arma dos fracos."
> >
> > ===========================
> > Italo Moreira Campelo Maia
> > Graduado em Ciência da Computação - UECE
> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
> > Coordenador do Pug-CE
> > -----------------------------------------------------
> > http://www.italomaia.com/
> > http://twitter.com/italomaia/
> > http://eusouolobomau.blogspot.com/
> > -----------------------------------------------------
> > turtle linux 910 - http://tiny.cc/blogturtle910
> > ===========================
> >
>



-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 15:40
In data venerdì 03 settembre 2010 17:19:06, Italo Maia ha scritto:
> Totally agree. Something not bundled would be indeed best. Maybe a
> repository for flask modules/apps would be nice. So, someone could just
> build his project with this parts, like a admin for mongo or SA (or some
> other stuff), a blog, stuff and stuff. Basically, this would mean no
> bundled "evil coupling" stuff and apps could still look powerful.

Yes, and also website wireframes or other types of module systems.
A repository means standard stuff, I think that it's better a collection of 
links like "Flask snippets" so are not standard things. I wish Flask a micro-
framework.

> Aaaaanyway, my 2 cents in the current discussion: i find flask modules a
> really nice approach. Maybe, there could be some kind of filter one could
> attach to a module instance before registering it to make the behavior
> Davide said to work. Making a framework over flask could work and all, but
> that would just create another turbogears. Can't see much advantage to
> that.

Just to say that how modules are technically implemented in Flask do not 
permits to do things in different manner. Their are integrated in Flask like 
the Django ORM in Django.

There is the possibility to use the actual Flask modules, but outside Flask in 
an optional (and not forced) way. This is a great thing. So I wish that this 
possibility exist because free me to make my own module system and also let 
others to do things in different manners than me.

> My humble me really thinks keeping the "Lego way of life" in flask could
> really show itself advantegeous, without all the django coupling.

Yep! :D

Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-03 @ 15:44
Perhaps if the "module loader" in Flask was a separate class that you
could swap out.

Something like:

app.module_loader_class = MyCustomLoader()
app.register_module(...)

That would allow the custom behaviour you are looking for.

Perhaps something to ask Armin about.

On 3 September 2010 16:40, Davide Muzzarelli <d.muzzarelli@dav-muz.net> wrote:
> In data venerdì 03 settembre 2010 17:19:06, Italo Maia ha scritto:
>> Totally agree. Something not bundled would be indeed best. Maybe a
>> repository for flask modules/apps would be nice. So, someone could just
>> build his project with this parts, like a admin for mongo or SA (or some
>> other stuff), a blog, stuff and stuff. Basically, this would mean no
>> bundled "evil coupling" stuff and apps could still look powerful.
>
> Yes, and also website wireframes or other types of module systems.
> A repository means standard stuff, I think that it's better a collection of
> links like "Flask snippets" so are not standard things. I wish Flask a micro-
> framework.
>
>> Aaaaanyway, my 2 cents in the current discussion: i find flask modules a
>> really nice approach. Maybe, there could be some kind of filter one could
>> attach to a module instance before registering it to make the behavior
>> Davide said to work. Making a framework over flask could work and all, but
>> that would just create another turbogears. Can't see much advantage to
>> that.
>
> Just to say that how modules are technically implemented in Flask do not
> permits to do things in different manner. Their are integrated in Flask like
> the Django ORM in Django.
>
> There is the possibility to use the actual Flask modules, but outside Flask in
> an optional (and not forced) way. This is a great thing. So I wish that this
> possibility exist because free me to make my own module system and also let
> others to do things in different manners than me.
>
>> My humble me really thinks keeping the "Lego way of life" in flask could
>> really show itself advantegeous, without all the django coupling.
>
> Yep! :D
>
> Davide Muzzarelli
> www.dav-muz.net
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 16:30
In data venerdì 03 settembre 2010 17:44:04, Dan Jacob ha scritto:
> Perhaps if the "module loader" in Flask was a separate class that you
> could swap out.
> 
> Something like:
> 
> app.module_loader_class = MyCustomLoader()
> app.register_module(...)
> 
> That would allow the custom behaviour you are looking for.
> 
> Perhaps something to ask Armin about.

Don't scale down but may be a solution.
I thing that don't scale down because Flask will have additional 
functionalities in order to run the modules.

In my opinion I prefer to have Flask more configurable in order to add things 
from outside. This leave Flask light and thin.

This is only a proposal, you can try it in the fork.

Actually the Flask's workflow is this:

1. [We] Create a Flask instance.
2. Flask read some internal configuration and prepare some things that you 
can't change.
3. [We] Configure only something because it is not possible to configure all, 
because some decisions are just taken by Flask.__init__ and some other 
configurations are hard coded.
4. [We] Tell Flask to run().
5. Flask run the server.

I found that the problem is between points 2 and 3.

I show you the workflow that I have in mind and that I build in my fork:

1. [We] Create a Flask instance (with or wihout a custom configuration).
2. [We] Configure Flask (here it is possible to set up Flask to act like we 
want).
3. [We] Tell Flask to run().
4. Flask use the configuration to prepare the things.
5. Flask run the server.

In reality there are only very few minor things that I changed inside the 
Flask.__init__ method. Moving those the compatibility remain and it is now 
possible to configure Flask after the initialization without subclassing it.

If you read the Frawz.create_app() function you can discover that it only set 
some variables. If you change that function you can create the behavior that 
you want. Simply.

Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-03 @ 15:30
On 3 September 2010 16:19, Italo Maia <italo.maia@gmail.com> wrote:
> Totally agree. Something not bundled would be indeed best. Maybe a
> repository for flask modules/apps would be nice. So, someone could just
> build his project with this parts, like a admin for mongo or SA (or some
> other stuff), a blog, stuff and stuff. Basically, this would mean no bundled
> "evil coupling" stuff and apps could still look powerful.
>

Some kind of scaffolding / paster based templates may be the answer here.

> Aaaaanyway, my 2 cents in the current discussion: i find flask modules a
> really nice approach. Maybe, there could be some kind of filter one could
> attach to a module instance before registering it to make the behavior
> Davide said to work. Making a framework over flask could work and all, but
> that would just create another turbogears. Can't see much advantage to that.

Turbogears 3 -  now based on Flask !

>
> My humble me really thinks keeping the "Lego way of life" in flask could
> really show itself advantegeous, without all the django coupling.
>
> ps: Lot of people are facing Ryan's problem and running for pylons to work
> around that, but, if you take a close look, flask is much more of a piece of
> art than pylons. I think there is tremendous space to grow in this matter.
>
I think what may be needed is clearer documentation, if a lot of
people are getting confused about the way one should build larger
applications.
> 2010/9/3 Dan Jacob <danjac354@gmail.com>
>>
>> The problem with an admin app is that you need to be able to handle
>> different backends. Django comes with a prepackaged ORM,
>> authentication etc, which makes it a lot easier to have a ready admin
>> app; the problem with that is you lose the flexibility.
>>
>> It *might* be possible to have a generic framework on top of Flask for
>> building admin apps, but the time taken to configure all the various
>> options (CouchDB ? SQLAlchemy ? OpenID ? etc etc) might outweigh any
>> real benefit.
>>
>> Most frameworks seem to manage fine without an admin app, as in
>> general this is something that is very project-specific. That said
>> it's probably THE selling point for Django (some might even say the
>> ONLY selling point ;-))
>>
>> On 3 September 2010 11:01, Italo Maia <italo.maia@gmail.com> wrote:
>> > There you go! http://github.com/italomaia/flask looks nice. Could be
>> > more
>> > "modular" maybe. When i saw "admin" in apps, almost drop a tear here.
>> > Flask
>> > soooo need a admin app.
>> >
>> > 2010/9/3 Stephane Wirtel <stephane@wirtel.be>
>> >>
>> >> Ok, Show me the result and may be, I will add something if I have time.
>> >>
>> >> Regards,
>> >> On 09/03/2010 11:09 AM, Italo Maia wrote:
>> >> > I'll be forking the skeleton here and add some stuff i find cool.
>> >> > Tell
>> >> > me what you think. = ]
>> >> >
>> >> > 2010/9/3 Stephane Wirtel <stephane@wirtel.be
>> >> > <mailto:stephane@wirtel.be>>
>> >> >
>> >> >     Hi Italo,
>> >> >
>> >> >     May be a small bug.
>> >> >     Currently he loads the views but not the models.py
>> >> >
>> >> >     We can use a python file for the configuration.
>> >> >
>> >> >     The manage could use this file for the creation of the database
>> >> > and
>> >> >     for the loading of the modules.
>> >> >
>> >> >     Regards,
>> >> >
>> >> >     Stéphane
>> >> >
>> >> >     On 09/03/2010 09:47 AM, Italo Maia wrote:
>> >> >     > My pleasure, bruce! ö/
>> >> >     >
>> >> >     > Anton, the skeleton project you posted does not work for
>> >> > createdb,
>> >> >     > right? Take a look at the code bruce posted. It has a
>> >> > workaround
>> >> > for
>> >> >     > that. It would be nice to have a manage.py in your skeleton
>> >> > too,
>> >> > that
>> >> >     > could accept some commands like runserver, createdb and stuff
>> >> > like
>> >> >     that.
>> >> >     > What you think? If the functions were there, someone could
>> >> > easely
>> >> > use
>> >> >     > flask-script extension with them.
>> >> >     >
>> >> >     > 2010/9/2 bruce bushby <bruce.bushby@googlemail.com
>> >> >     <mailto:bruce.bushby@googlemail.com>
>> >> >     > <mailto:bruce.bushby@googlemail.com
>> >> >     <mailto:bruce.bushby@googlemail.com>>>
>> >> >     >
>> >> >     >
>> >> >     >     A while back I encountered the same problem and being new
>> >> > to
>> >> >     python
>> >> >     >     didn't help either.
>> >> >     >
>> >> >     >     I posted a message to the list asking to hire a flask
>> >> > developer to
>> >> >     >     code me some small examples which I could follow, Italo
>> >> > Maia
>> >> >     offered
>> >> >     >     his services and I must say the examples have helped me
>> >> >     >     understand a lot more. The key was to have a very simple
>> >> > website
>> >> >     >     that starts of in the "small format" showing the changes on
>> >> >     the way
>> >> >     >     to the "big layout"
>> >> >     >
>> >> >     >     Perhaps they can be added to the examples folder...which is
>> >> >     looking
>> >> >     >     a little bare.
>> >> >     >
>> >> >     >     I've attached them in hope they'll help others, I did
>> >> > purchase
>> >> >     them
>> >> >     >     so I assume I have the right to hand them out. I've got
>> >> > another
>> >> >     >     example which has some css but I would need to remove my
>> >> >     "branding"
>> >> >     >     first. Thanks Italo for coding them!
>> >> >     >
>> >> >     >
>> >> >     >     Bruce
>> >> >     >
>> >> >     >
>> >> >     >
>> >> >     >
>> >> >     >     On Thu, Sep 2, 2010 at 7:57 AM, Dan Jacob
>> >> > <danjac354@gmail.com
>> >> >     <mailto:danjac354@gmail.com>
>> >> >     >     <mailto:danjac354@gmail.com <mailto:danjac354@gmail.com>>>
>> >> > wrote:
>> >> >     >
>> >> >     >         https://bitbucket.org/danjac/newsmeme/
>> >> >     >         http://github.com/mitsuhiko/flask/tree/website
>> >> >     >
>> >> >     >         On 2 September 2010 01:29, Ryan Cole
>> >> > <betawarz@gmail.com
>> >> >     <mailto:betawarz@gmail.com>
>> >> >     >         <mailto:betawarz@gmail.com
>> >> > <mailto:betawarz@gmail.com>>>
>> >> >     wrote:
>> >> >     >         > Hi all,
>> >> >     >         > I'm trying to achieve the directory structure
>> >> > mentioned
>> >> > very
>> >> >     >         briefly at the
>> >> >     >         > end of the packages documentation. The direct
>> >> > permalink
>> >> > is
>> >> >     >         >
>> >> >     >         here:
>> >> >
>> >> > http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>> >> >     >         > I'm a little confused as to what goes where. I
>> >> >     understand the
>> >> >     >         section prior
>> >> >     >         > to the Modules and Resources section, but I feel like
>> >> > the
>> >> >     >         documentation
>> >> >     >         > makes a quick jump to the section that I'm interested
>> >> > in.
>> >> >     >         > Would I still create my Flask "app" object in the
>> >> >     outter-most
>> >> >     >         __init__.py
>> >> >     >         > file, and then use app.register_module from there?
>> >> > And
>> >> > then,
>> >> >     >         in the
>> >> >     >         > __init__.py files inside each Module's directory
>> >> > create
>> >> > the
>> >> >     >         Module objects?
>> >> >     >         > This would leave the views.py file empty, which
>> >> > confuses
>> >> >     me a
>> >> >     >         little. Would
>> >> >     >         > I instead leave __init__.py in each Module's
>> >> > directory
>> >> >     empty,
>> >> >     >         and create the
>> >> >     >         > Module objects inside the view.py file, then?
>> >> >     >         > I guess I'm just a little confused. Perhaps does
>> >> > anyone
>> >> >     have a
>> >> >     >         complete but
>> >> >     >         > simple example on github, or something?
>> >> >     >         > Thank you,
>> >> >     >         > Ryan
>> >> >     >
>> >> >     >
>> >> >     >
>> >> >     >
>> >> >     >
>> >> >     > --
>> >> >     > "A arrogância é a arma dos fracos."
>> >> >     >
>> >> >     > ===========================
>> >> >     > Italo Moreira Campelo Maia
>> >> >     > Graduado em Ciência da Computação - UECE
>> >> >     > Desenvolvedor WEB e Desktop (Java, Python, Lua)
>> >> >     > Coordenador do Pug-CE
>> >> >     > -----------------------------------------------------
>> >> >     > http://www.italomaia.com/
>> >> >     > http://twitter.com/italomaia/
>> >> >     > http://eusouolobomau.blogspot.com/
>> >> >     > -----------------------------------------------------
>> >> >     > turtle linux 910 - http://tiny.cc/blogturtle910
>> >> >     > ===========================
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > "A arrogância é a arma dos fracos."
>> >> >
>> >> > ===========================
>> >> > Italo Moreira Campelo Maia
>> >> > Graduado em Ciência da Computação - UECE
>> >> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
>> >> > Coordenador do Pug-CE
>> >> > -----------------------------------------------------
>> >> > http://www.italomaia.com/
>> >> > http://twitter.com/italomaia/
>> >> > http://eusouolobomau.blogspot.com/
>> >> > -----------------------------------------------------
>> >> > turtle linux 910 - http://tiny.cc/blogturtle910
>> >> > ===========================
>> >>
>> >
>> >
>> >
>> > --
>> > "A arrogância é a arma dos fracos."
>> >
>> > ===========================
>> > Italo Moreira Campelo Maia
>> > Graduado em Ciência da Computação - UECE
>> > Desenvolvedor WEB e Desktop (Java, Python, Lua)
>> > Coordenador do Pug-CE
>> > -----------------------------------------------------
>> > http://www.italomaia.com/
>> > http://twitter.com/italomaia/
>> > http://eusouolobomau.blogspot.com/
>> > -----------------------------------------------------
>> > turtle linux 910 - http://tiny.cc/blogturtle910
>> > ===========================
>> >
>
>
>
> --
> "A arrogância é a arma dos fracos."
>
> ===========================
> Italo Moreira Campelo Maia
> Graduado em Ciência da Computação - UECE
> Desenvolvedor WEB e Desktop (Java, Python, Lua)
> Coordenador do Pug-CE
> -----------------------------------------------------
> http://www.italomaia.com/
> http://twitter.com/italomaia/
> http://eusouolobomau.blogspot.com/
> -----------------------------------------------------
> turtle linux 910 - http://tiny.cc/blogturtle910
> ===========================
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Ryan Cole
Date:
2010-09-03 @ 16:41
On Fri, Sep 3, 2010 at 10:30 AM, Dan Jacob <danjac354@gmail.com> wrote:

> I think what may be needed is clearer documentation, if a lot of
> people are getting confused about the way one should build larger
> applications.
>

I do think the documentation there could be worked on. I like to consider
myself a pretty smart guy, but it took several attempts for me to achieve
that final "large application" directory structure. When I did get it
working, I didn't really like the complexity that I felt like it introduced.
I probably did it wrong, but it just felt like everything was more spread
out than before. I didn't feel like the individual Modules were very "tight"
or encapsulated.
I eventually just revered back to that single views directory, and have
seperate module files in their for each seperated logic of my site - core,
authentication, etc. Then I have the templates directory. This just feels
much simpler, clean and intuitive to me.

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Thadeus Burgess
Date:
2010-09-03 @ 17:23
I ended up using this structure. I find it allows me to have two
applications easily share the same codebase, but keep them separated
by domain. More often than not I have to turn around and write an app
for another domain that uses a small subset of the larger project, and
they all have to be able to communicate with each other. The backend
needs access to everything.

The Project
\setup.py
\docs <- sphinx
\etc <- contains configuration files.
\theproject <- just a package container
\\lib <- any code for the project
\\models <- any models for the project
\\com <- any third party sources for the project.
\\apps
\\\frontend <- self contained flask app, with its own templates and
views. It can however pull from theproject lib and access all of the
same modules/code
\\\\__init__.py <- create_app
\\\\views\viewA.py/viewB.py <- modules
\\\\templates
\\\backend <- same as frontend, but contains the admin panel and whatnot.
\\\someothersite

--
Thadeus





On Fri, Sep 3, 2010 at 11:41 AM, Ryan Cole <betawarz@gmail.com> wrote:
> On Fri, Sep 3, 2010 at 10:30 AM, Dan Jacob <danjac354@gmail.com> wrote:
>>
>> I think what may be needed is clearer documentation, if a lot of
>> people are getting confused about the way one should build larger
>> applications.
>
> I do think the documentation there could be worked on. I like to consider
> myself a pretty smart guy, but it took several attempts for me to achieve
> that final "large application" directory structure. When I did get it
> working, I didn't really like the complexity that I felt like it introduced.
> I probably did it wrong, but it just felt like everything was more spread
> out than before. I didn't feel like the individual Modules were very "tight"
> or encapsulated.
>
> I eventually just revered back to that single views directory, and have
> seperate module files in their for each seperated logic of my site - core,
> authentication, etc. Then I have the templates directory. This just feels
> much simpler, clean and intuitive to me.

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 10:30
In data venerdì 03 settembre 2010 12:07:53, Dan Jacob ha scritto:
> The problem with an admin app is that you need to be able to handle
> different backends. Django comes with a prepackaged ORM,
> authentication etc, which makes it a lot easier to have a ready admin
> app; the problem with that is you lose the flexibility.
> 
> It *might* be possible to have a generic framework on top of Flask for
> building admin apps, but the time taken to configure all the various
> options (CouchDB ? SQLAlchemy ? OpenID ? etc etc) might outweigh any
> real benefit.
> 
> Most frameworks seem to manage fine without an admin app, as in
> general this is something that is very project-specific. That said
> it's probably THE selling point for Django (some might even say the
> ONLY selling point ;-))

It's what I'm traying to do.

I developed an apps package that create the app from a settings file like 
Django. It load all: database, models, commands, locale, template filters and 
contexts, error handlers (email and logs) and urls.

Clearly it is for not so little apps. For so little apps it is easy to use 
Flask alone.

I'm almost ready to load configurable, and not static, modules. Soon I will add 
basic modules like Sites, Flatpages, Admin, Users etc. The urls are not 
blocked so are changeable, templates can be overridden etc.

The bad thing is that it is not obtainable whithout remove the actual Flask 
modules because they block urls, templates and views. I'm really sorry for 
this. There are other things like configuration variables but fortunately are 
easy to modify mainaining the backward compatibility.

I'm doing so because hard code all every time is a lot of effort if you build 
more than few websites and it is impossible to create a community of modules 
if the developers are forced to customize every module only for adapt urls and 
views. I prefer configuration than hard coding.

Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-03 @ 10:32
> It's what I'm traying to do.
>
> I developed an apps package that create the app from a settings file like
> Django. It load all: database, models, commands, locale, template filters and
> contexts, error handlers (email and logs) and urls.
>

Which database ? Does it work for multiple backends ?

> Clearly it is for not so little apps. For so little apps it is easy to use
> Flask alone.
>
> I'm almost ready to load configurable, and not static, modules. Soon I will add
> basic modules like Sites, Flatpages, Admin, Users etc. The urls are not
> blocked so are changeable, templates can be overridden etc.
>

What do you mean by "blocked" ?


> The bad thing is that it is not obtainable whithout remove the actual Flask
> modules because they block urls, templates and views. I'm really sorry for
> this. There are other things like configuration variables but fortunately are
> easy to modify mainaining the backward compatibility.
>

Again what do you mean ? How are they "blocked" ?

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 11:20
In data venerdì 03 settembre 2010 12:32:47, Dan Jacob ha scritto:
> Which database ? Does it work for multiple backends ?

The SQLAlchemy extension. I use it because I suppose that it is used by most 
of Flask's developers.
It do not load SQLAlchemy if there is not the SQLALCHEMY_DATABASE_URI variable 
in the settings file.

> What do you mean by "blocked" ?

Without a fork it is impossible to:
- create custom urls based on an existing module;
- use custom or dinamic subdomains, also based on an existing modules;
- change the urls of an existing module;
- change the views of an existing module;
- share existing modules with multiple applications in the same machine in 
different manners without a copy-paste-modify.
I think that this block is enforced by the use of decorators for views: good 
for little applications but a constraint for modules.

If you wish I could give the technical details. I set the fork public at the 
address http://github.com/Davmuz/flask

If someone is interested, I will give also the package that configure a whole 
application from a settings file in half a minute.

> Again what do you mean ? How are they "blocked" ?

Other things are:
- some thing are created during the initialization of Flask and not in the 
run() time, this make impossible to configure several parameters before without 
subclassing Flask;
- loading of templates from multiple different custom sources.
- the creation of others types of module systems.

Not so much, just a 0.5% of the code or less.


For doing this I tried to subclass Flask but modules and urls were impossible 
to change without a fork. So I do it for me. I'm hoping that with some 
feedback I can improve this and give some help to peoples that have the same 
needs.

Thank you Dan to give me some attention and the possibility to explain this. 
Sorry if I appear aggressive, I'm really not and this is not a rant! I only 
wish to scratch my business problem giving an help to the author (he helped me 
writing Flask and the others packages).

More details are on the wiki http://wiki.github.com/Davmuz/flask/

Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-03 @ 11:24
On 3 September 2010 12:20, Davide Muzzarelli <d.muzzarelli@dav-muz.net> wrote:
> In data venerdì 03 settembre 2010 12:32:47, Dan Jacob ha scritto:
>> Which database ? Does it work for multiple backends ?
>
> The SQLAlchemy extension. I use it because I suppose that it is used by most
> of Flask's developers.

How do you know this ?

> It do not load SQLAlchemy if there is not the SQLALCHEMY_DATABASE_URI variable
> in the settings file.
>
>> What do you mean by "blocked" ?
>
> Without a fork it is impossible to:
> - create custom urls based on an existing module;

Sorry ? You can do this:

app.register_module(mod, url_prefix="/blah/")

> - use custom or dinamic subdomains, also based on an existing modules;
> - change the urls of an existing module;
> - change the views of an existing module;
> - share existing modules with multiple applications in the same machine in
> different manners without a copy-paste-modify.

Not sure what this means. Modules can be shared; just import them from
a common package.

> I think that this block is enforced by the use of decorators for views: good
> for little applications but a constraint for modules.
>
> If you wish I could give the technical details. I set the fork public at the
> address http://github.com/Davmuz/flask
>
> If someone is interested, I will give also the package that configure a whole
> application from a settings file in half a minute.
>
>> Again what do you mean ? How are they "blocked" ?
>
> Other things are:
> - some thing are created during the initialization of Flask and not in the
> run() time, this make impossible to configure several parameters before without
> subclassing Flask;

Use the application factory pattern.

> - loading of templates from multiple different custom sources.
> - the creation of others types of module systems.
>
> Not so much, just a 0.5% of the code or less.
>
>
> For doing this I tried to subclass Flask but modules and urls were impossible
> to change without a fork. So I do it for me. I'm hoping that with some
> feedback I can improve this and give some help to peoples that have the same
> needs.
>
> Thank you Dan to give me some attention and the possibility to explain this.
> Sorry if I appear aggressive, I'm really not and this is not a rant! I only
> wish to scratch my business problem giving an help to the author (he helped me
> writing Flask and the others packages).
>
> More details are on the wiki http://wiki.github.com/Davmuz/flask/
>
> Davide Muzzarelli
> www.dav-muz.net
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 12:09
In data venerdì 03 settembre 2010 13:24:54, Dan Jacob ha scritto:
> > The SQLAlchemy extension. I use it because I suppose that it is used by
> > most of Flask's developers.
> 
> How do you know this ?

I written that I suppose. I read comments from the Django community and 
Flask's one, SQLAlchemy is what I read 99% of the time. However I have to base 
the Admin and other future modules on a database.

It is still possible to use another because I leverage the 
SQLALCHEMY_DATABASE_URI that have the "SQLALCHEMY" word inside that do not 
clash with different database extensions.

> > Without a fork it is impossible to:
> > - create custom urls based on an existing module;
> 
> Sorry ? You can do this:
> 
> app.register_module(mod, url_prefix="/blah/")

Probably I have not explained well.

That you write is only a prefix.
Very often, expecially for SEO intentions or for remove unuseful views, I have 
to change internal urls and also replace views with advanced or simpler ones.

A simple case of a News module that have these urls: '/news/', 
'/news/archive/', '/news/detail/'.
If I want to remove the archive I can't do it, or I have to modify the module 
hard coding.
If I want to extend the view with more parameters I can't do it, or I have to 
modify the module hard coding.
If I want to translate te url (like '/novita/', '/archivio/novita/', '/leggi-
novita/') I can't do it, or I have to modify the module hard coding.
If I want to use a module with two or more different manners in the same site 
(I do it sometime, like '/news/company/', '/news/archive/', '/news/events/', 
'/latest/news/', '/news/<id>/') I can't do it, or I have to modify the module 
hard coding.

News is a really easy module, think about a eCommerce module.

It is still possible that I completely misunderstood what actual modules do, 
so please tell me if there are solutions to these problems (that I have to 
solve everyday) without take the module, copy it and modify it everytime for 
many websites.

The system is simple, very configurable like Django's one, but more configurable 
because it is possible to change how modules works for really bigger 
applications.

> Not sure what this means. Modules can be shared; just import them from
> a common package.

I know it but it's not enough, the problem that I wish to solve is above.

> Use the application factory pattern.

I do it but this force me to fork Flask because these thing are impossible 
without. So I give the source on github.

I'm also ready to see the Armin's new modules if those change somethings and 
to maintain my fork in sync with him. I just tell that before. I do not love 
to maintain a fork, is a waste of time, but I really need it in order to solve 
these problems.

Actually I'm waiting for feedback if someones have the same needs.

Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Dan Jacob
Date:
2010-09-03 @ 12:27
On 3 September 2010 13:09, Davide Muzzarelli <d.muzzarelli@dav-muz.net> wrote:
> In data venerdì 03 settembre 2010 13:24:54, Dan Jacob ha scritto:
>> > The SQLAlchemy extension. I use it because I suppose that it is used by
>> > most of Flask's developers.
>>
>> How do you know this ?
>
> I written that I suppose. I read comments from the Django community and
> Flask's one, SQLAlchemy is what I read 99% of the time. However I have to base
> the Admin and other future modules on a database.
>

This is the crux of the problem, as I stated earlier in this thread.

Why choose Django over Flask and vice versa ? Minor (in practical
terms) design differences aside, they have different philosophies.

Django is optimized to building large websites from large components
(apps). Some components (admin, auth) come with Django, some are 3rd
party, some you write yourself, plus a bit of glue code (settings,
templates etc). But the intention is to be able to wire together some
apps and you are done, bar the design phase.

This is a very powerful concept, and for certain projects it's ideal.
However the tradeoff is that you give up flexibility. You have to use
this template engine, that ORM, and (if you want to use admin and just
about every other app out there) an authentication model that
dictates, for example, that you shall have a username of 30
characters.

For other projects that's not ideal. You are not building a
cookie-cutter website but something different - maybe porting a legacy
application, maybe something quite new. You need the flexibility of
choosing Couch or Redis or some SQL backend; you need to be able to
build something from scratch with control over components. This is
where a framework like Flask (and others - Catalyst for example) is
most desirable.

If Flask where to have an "admin" app then it would simply be another
Django, with all the constraints of Django. We don't need that; we
already have Django. What we do need is a Python framework capable of
simplicity and flexibility, that allows you to use what you need and
discard the rest. One may argue that Pylons already does this, and
that Flask competes with Pylons; fine. But we don't need to just
re-write Django. Any admin app you make that assumes the same thing
the Django admin assumes would just make Flask into Django, which
seems to me rather pointless.

Now what would be clever, and I'm not sure it's doable but would love
to be proven wrong, is a framework built on top of Flask that would
allow different backends (database backends and
authentication/permissions), so you can create a CRUD interface using
SQLAlchemy or MongoDB or whatever, which allows OpenID authentication
and customizable permissions. That would be useful, but as I've said,
I'm not sure it's doable (in the sense that it wouldn't require a ton
of configuration and glue to get it working).


> It is still possible to use another because I leverage the
> SQLALCHEMY_DATABASE_URI that have the "SQLALCHEMY" word inside that do not
> clash with different database extensions.
>
>> > Without a fork it is impossible to:
>> > - create custom urls based on an existing module;
>>
>> Sorry ? You can do this:
>>
>> app.register_module(mod, url_prefix="/blah/")
>
> Probably I have not explained well.
>
> That you write is only a prefix.
> Very often, expecially for SEO intentions or for remove unuseful views, I have
> to change internal urls and also replace views with advanced or simpler ones.
>
> A simple case of a News module that have these urls: '/news/',
> '/news/archive/', '/news/detail/'.
> If I want to remove the archive I can't do it, or I have to modify the module
> hard coding.
> If I want to extend the view with more parameters I can't do it, or I have to
> modify the module hard coding.
> If I want to translate te url (like '/novita/', '/archivio/novita/', '/leggi-
> novita/') I can't do it, or I have to modify the module hard coding.
> If I want to use a module with two or more different manners in the same site
> (I do it sometime, like '/news/company/', '/news/archive/', '/news/events/',
> '/latest/news/', '/news/<id>/') I can't do it, or I have to modify the module
> hard coding.
>
> News is a really easy module, think about a eCommerce module.
>
> It is still possible that I completely misunderstood what actual modules do,
> so please tell me if there are solutions to these problems (that I have to
> solve everyday) without take the module, copy it and modify it everytime for
> many websites.
>
> The system is simple, very configurable like Django's one, but more configurable
> because it is possible to change how modules works for really bigger
> applications.
>
>> Not sure what this means. Modules can be shared; just import them from
>> a common package.
>
> I know it but it's not enough, the problem that I wish to solve is above.
>
>> Use the application factory pattern.
>
> I do it but this force me to fork Flask because these thing are impossible
> without. So I give the source on github.
>
> I'm also ready to see the Armin's new modules if those change somethings and
> to maintain my fork in sync with him. I just tell that before. I do not love
> to maintain a fork, is a waste of time, but I really need it in order to solve
> these problems.
>
> Actually I'm waiting for feedback if someones have the same needs.
>
> Davide Muzzarelli
> www.dav-muz.net
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 13:10
In data venerdì 03 settembre 2010 14:27:00, Dan Jacob ha scritto:
> Django is optimized to building large websites from large components
> (apps). Some components (admin, auth) come with Django, some are 3rd
> party, some you write yourself, plus a bit of glue code (settings,
> templates etc). But the intention is to be able to wire together some
> apps and you are done, bar the design phase.

Exactly, I actually need that components system because this save my business 
of an huge amount of days per month.

> This is a very powerful concept, and for certain projects it's ideal.
> However the tradeoff is that you give up flexibility. You have to use
> this template engine, that ORM, and (if you want to use admin and just
> about every other app out there) an authentication model that
> dictates, for example, that you shall have a username of 30
> characters.

Exactly, and this is the classic problem of Coupling and Cohesion.

I think that it's not avoidable, but there are manners to make it less 
problematic.

> For other projects that's not ideal. You are not building a
> cookie-cutter website but something different - maybe porting a legacy
> application, maybe something quite new. You need the flexibility of
> choosing Couch or Redis or some SQL backend; you need to be able to
> build something from scratch with control over components. This is
> where a framework like Flask (and others - Catalyst for example) is
> most desirable.

Flask is fantastic in this. But not for modules, because it suppose that all 
use a system in that way! I can't use a module in another manner without fork 
it!


The code that I writted permit to use Flask exactly like before, no 
differences! I only removed modules because are inflexible.
I expanded only the possibility of configuration of the things that was hard 
coded (like the static path, routers and template sources).

This open the possibility to use Flask for a developer that don't like Flask 
modules. No more.

> If Flask where to have an "admin" app then it would simply be another
> Django, with all the constraints of Django. We don't need that; we
> already have Django. What we do need is a Python framework capable of
> simplicity and flexibility, that allows you to use what you need and
> discard the rest. One may argue that Pylons already does this, and
> that Flask competes with Pylons; fine. But we don't need to just
> re-write Django. Any admin app you make that assumes the same thing
> the Django admin assumes would just make Flask into Django, which
> seems to me rather pointless.
> 
> Now what would be clever, and I'm not sure it's doable but would love
> to be proven wrong, is a framework built on top of Flask that would
> allow different backends (database backends and
> authentication/permissions), so you can create a CRUD interface using
> SQLAlchemy or MongoDB or whatever, which allows OpenID authentication
> and customizable permissions. That would be useful, but as I've said,
> I'm not sure it's doable (in the sense that it wouldn't require a ton
> of configuration and glue to get it working).

Fantastic! All what you write is exactly where I started! :)

I love Django for many thing but, unfortunately, it is impossible to extend 
over close limits. A classic example is the Django ORM: if you do not like it 
you cannot replace it because it is integrated in the system so much that you 
have to rewrite all (and not only the contrib apps that are the minor things).

What I wish is to create my custom create_app() function where configure Flask 
to use another type of modules like the Django one (or, for another developer, 
his particular module system).
Over this I can create my reusable modules and configure them outside Flask.

I do it and it is almost complete. Are only 144 lines of code.
It's only a scratch for testing and I'm sure that it could be done better, see 
the attachment. As you can see I added all outside Flask.

The basic app start with the following code, the settings are in settings.py 
as you can see but could be also in an object:

== manage.py ==
from frawz import create_app

if __name__ == '__main__':
    manager = create_app(__name__, 'settings')
    manager.run()

== Example of a settings.py file ==
DEBUG = True

STATIC_ROOT = 'www/static'
URLS = 'urls.get_url_map'
SQLALCHEMY_DATABASE_URI = 'postgres:///mydatabase'

CONTEXT_PROCESSORS = ('context_processors.default',)
MODELS = ('frawz.sites.models', 'frawz.flatpages', 'contacts')
FILTERS = ('frawz.utils.context_processors.markup',)

ADMINS = ('info@mysite.com',)
EMAIL_SUBJECT_PREFIX = '[mysite.com] '
EMAIL_SERVER = ('127.0.0.1', '1025')
TEMPLATES = (), ('flask.utils',)

BABEL_DEFAULT_LOCALE = 'it'
LANGUAGES = ('it', 'en', 'fr')
LOCALESELECTOR = 'frawz.i18n.get_locale_by_subdomain'

== Example of a urls.py file ==
from flask.wrappers import Map, Rule

def get_url_map(app):
    rules = [
        Rule(app.static_path + '/<path:filename>', \
            view_func=app.send_static_file, endpoint='media'),
        Rule('/', endpoint='views.index'),
        Rule('/<string(length=2):lang_code>', endpoint='views.locale_index'),
    ]
    return Map(rules)


Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 13:23
Ah, I forgotten, a simple app is still possible:

== Based on the Flask documentation ==
from flask import Flask
app = Flask(__name__)

@app.url_map.route('/')
def hello():
    return "Hello World!"

if __name__ = '__main__':
    app.run()


Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Ryan Cole
Date:
2010-09-03 @ 14:41
We use MongoDB, with PyMongo. We used to use Django back when we used MySQL.
We eventually left Django because of the downsides mentioned prior - so much
of the framework now depends on the pre-packaged ORM and stuff. I'd imagine
this would be less of a problem if there were no Django Admin to make it
feel like you're missing out on something by not using their ORM. You also
lose authentication, sessions (i think?), etc.

We moved to Flask because it was so light weight, but allowed us to develop
much like we did while using Django. Jinja2 makes our templating the same,
WTForms gets our forms the same. We had to write our own authentication
mechanisms, but that turned out real cool.

I don't think I'll be going back to Django after using Flask, unless I plan
on using one of the supported SQL engines.

On Fri, Sep 3, 2010 at 8:23 AM, Davide Muzzarelli
<d.muzzarelli@dav-muz.net>wrote:

> Ah, I forgotten, a simple app is still possible:
>
> == Based on the Flask documentation ==
> from flask import Flask
> app = Flask(__name__)
>
> @app.url_map.route('/')
> def hello():
>    return "Hello World!"
>
> if __name__ = '__main__':
>    app.run()
>
>
> Davide Muzzarelli
> www.dav-muz.net
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Davide Muzzarelli
Date:
2010-09-03 @ 14:58
In data venerdì 03 settembre 2010 16:41:07, Ryan Cole ha scritto:
> We use MongoDB, with PyMongo. We used to use Django back when we used
> MySQL. We eventually left Django because of the downsides mentioned prior
> - so much of the framework now depends on the pre-packaged ORM and stuff.
> I'd imagine this would be less of a problem if there were no Django Admin
> to make it feel like you're missing out on something by not using their
> ORM. You also lose authentication, sessions (i think?), etc.

The Django ORM is coupled with a lot of things, also the forms! ^_^
A mess...

> We moved to Flask because it was so light weight, but allowed us to develop
> much like we did while using Django. Jinja2 makes our templating the same,
> WTForms gets our forms the same. We had to write our own authentication
> mechanisms, but that turned out real cool.
> 
> I don't think I'll be going back to Django after using Flask, unless I plan
> on using one of the supported SQL engines.

I think the same thing and I developed a similar system outside Flask in order 
to get what I like of Django (the configuration).

When I speak about an Admin module, I mean that I will develop it outside 
Flask because I need one for my clients and operators. I do not want absolutly 
standard modules or a module system like Django (or others) in Flask! I wish 
Flask free of that.

I tell this only for clearness.

Davide Muzzarelli
www.dav-muz.net

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
kevin beckford
Date:
2010-09-02 @ 09:17
> I've attached them in hope they'll help others, I did purchase them so I
> assume I have the right to hand them out.

This is very much appreciated.

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
bruce bushby
Date:
2010-09-02 @ 11:41
I forgot to mention Dan Jacob's newsmeme is an excellent example but I found
it a little advanced...although now it's starting to come in very
handy.....thanks Dan and congratulations!!



On Thu, Sep 2, 2010 at 10:17 AM, kevin beckford <chiggsy@lazyweb.ca> wrote:

> > I've attached them in hope they'll help others, I did purchase them so I
> > assume I have the right to hand them out.
>
> This is very much appreciated.
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Thadeus Burgess
Date:
2010-09-02 @ 07:11
Those don't really follow that same structure. They don't help at all
in exploring that application layout.

For some reason I don't think the layout that is mentioned in the docs
is even possible. It looks like Armin just threw that in the docs at
the last minute but its not a actual valid application structure.

--
Thadeus





On Thu, Sep 2, 2010 at 1:57 AM, Dan Jacob <danjac354@gmail.com> wrote:
> https://bitbucket.org/danjac/newsmeme/
> http://github.com/mitsuhiko/flask/tree/website
>
> On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com> wrote:
>> Hi all,
>> I'm trying to achieve the directory structure mentioned very briefly at the
>> end of the packages documentation. The direct permalink is
>> here: http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>> I'm a little confused as to what goes where. I understand the section prior
>> to the Modules and Resources section, but I feel like the documentation
>> makes a quick jump to the section that I'm interested in.
>> Would I still create my Flask "app" object in the outter-most __init__.py
>> file, and then use app.register_module from there? And then, in the
>> __init__.py files inside each Module's directory create the Module objects?
>> This would leave the views.py file empty, which confuses me a little. Would
>> I instead leave __init__.py in each Module's directory empty, and create the
>> Module objects inside the view.py file, then?
>> I guess I'm just a little confused. Perhaps does anyone have a complete but
>> simple example on github, or something?
>> Thank you,
>> Ryan
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-02 @ 07:51
On 09/02/2010 09:11 AM, Thadeus Burgess wrote:
> Those don't really follow that same structure. They don't help at all
> in exploring that application layout.
> 
> For some reason I don't think the layout that is mentioned in the docs
> is even possible. It looks like Armin just threw that in the docs at
> the last minute but its not a actual valid application structure.
> 
> --
> Thadeus
Hi Thadeus,

And which structure do you propose ?

Thanks

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Thadeus Burgess
Date:
2010-09-02 @ 08:16
http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources

I guess I just don't *get it*.

--
Thadeus





On Thu, Sep 2, 2010 at 2:51 AM, Stephane Wirtel <stephane@wirtel.be> wrote:
> On 09/02/2010 09:11 AM, Thadeus Burgess wrote:
>> Those don't really follow that same structure. They don't help at all
>> in exploring that application layout.
>>
>> For some reason I don't think the layout that is mentioned in the docs
>> is even possible. It looks like Armin just threw that in the docs at
>> the last minute but its not a actual valid application structure.
>>
>> --
>> Thadeus
> Hi Thadeus,
>
> And which structure do you propose ?
>
> Thanks
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Italo Maia
Date:
2010-09-02 @ 07:25
Ryan, the "large application" directory structure is achievable. Create a
apps/ directory in the project root. Throw a __init__.py there. Create a
views.py file in these directories and, inside them, create an app module
like:

from flask import Module
app = Module(__name__, 'app_name', url_prefix='/prefix')

then register your views with this module.

In the project root directory, create something like main.py and instantiate
your Flask app there.

# this goes in the main.py file
from flask import Flask
app = Flask()

Create your project factory as written in docs then register all the app
modules within yout Flask instance. You could use some tricks here.
Something like:

# create a list with the app names
installed_apps = ['app_x', 'app_y', 'app_z']

then load the app object from the views module in each app using the
__import__ then register the modules with yout Flask instance.

Something like:

for app_name in installed_apps:
module = __import__('apps.%s.views', fromlist=['app'])
# app is a flask instance here, not a module
app.register_module(module.app)

You could add some hasattr here and there, but this is pretty much it. Hope
that helped! I've been trying some stuff with flask and that worked for me.

2010/9/2 Thadeus Burgess <thadeusb@thadeusb.com>

> Those don't really follow that same structure. They don't help at all
> in exploring that application layout.
>
> For some reason I don't think the layout that is mentioned in the docs
> is even possible. It looks like Armin just threw that in the docs at
> the last minute but its not a actual valid application structure.
>
> --
> Thadeus
>
>
>
>
>
> On Thu, Sep 2, 2010 at 1:57 AM, Dan Jacob <danjac354@gmail.com> wrote:
> > https://bitbucket.org/danjac/newsmeme/
> > http://github.com/mitsuhiko/flask/tree/website
> >
> > On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com> wrote:
> >> Hi all,
> >> I'm trying to achieve the directory structure mentioned very briefly at
> the
> >> end of the packages documentation. The direct permalink is
> >> here:
> http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
> >> I'm a little confused as to what goes where. I understand the section
> prior
> >> to the Modules and Resources section, but I feel like the documentation
> >> makes a quick jump to the section that I'm interested in.
> >> Would I still create my Flask "app" object in the outter-most
> __init__.py
> >> file, and then use app.register_module from there? And then, in the
> >> __init__.py files inside each Module's directory create the Module
> objects?
> >> This would leave the views.py file empty, which confuses me a little.
> Would
> >> I instead leave __init__.py in each Module's directory empty, and create
> the
> >> Module objects inside the view.py file, then?
> >> I guess I'm just a little confused. Perhaps does anyone have a complete
> but
> >> simple example on github, or something?
> >> Thank you,
> >> Ryan
> >
>



-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Anton Khodakivskiy
Date:
2010-09-02 @ 08:18
Hi , 

I'm pretty new to python and web development, so my experience is not 
overly reliable. 

Here is the flask project that follows the "Larger application" structure:
http://github.com/akhodakivskiy/flask/skeleton

$ python runserver.py 
and you will have two urls available from different modules:

localhost:5000/
localhost:5000/admin

Let me know what you think

On Sep 2, 2010, at 10:25 AM, Italo Maia wrote:

> Ryan, the "large application" directory structure is achievable. Create 
a apps/ directory in the project root. Throw a __init__.py there. Create a
views.py file in these directories and, inside them, create an app module 
like:
> 
> from flask import Module
> app = Module(__name__, 'app_name', url_prefix='/prefix')
> 
> then register your views with this module.
> 
> In the project root directory, create something like main.py and 
instantiate your Flask app there.
> 
> # this goes in the main.py file
> from flask import Flask
> app = Flask()
> 
> Create your project factory as written in docs then register all the app
modules within yout Flask instance. You could use some tricks here. 
Something like:
> 
> # create a list with the app names
> installed_apps = ['app_x', 'app_y', 'app_z']
> 
> then load the app object from the views module in each app using the 
__import__ then register the modules with yout Flask instance. 
> 
> Something like:
> 
> for app_name in installed_apps:
> module = __import__('apps.%s.views', fromlist=['app'])
> # app is a flask instance here, not a module
> app.register_module(module.app)
> 
> You could add some hasattr here and there, but this is pretty much it. 
Hope that helped! I've been trying some stuff with flask and that worked 
for me. 
> 
> 2010/9/2 Thadeus Burgess <thadeusb@thadeusb.com>
> Those don't really follow that same structure. They don't help at all
> in exploring that application layout.
> 
> For some reason I don't think the layout that is mentioned in the docs
> is even possible. It looks like Armin just threw that in the docs at
> the last minute but its not a actual valid application structure.
> 
> --
> Thadeus
> 
> 
> 
> 
> 
> On Thu, Sep 2, 2010 at 1:57 AM, Dan Jacob <danjac354@gmail.com> wrote:
> > https://bitbucket.org/danjac/newsmeme/
> > http://github.com/mitsuhiko/flask/tree/website
> >
> > On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com> wrote:
> >> Hi all,
> >> I'm trying to achieve the directory structure mentioned very briefly at the
> >> end of the packages documentation. The direct permalink is
> >> here: http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
> >> I'm a little confused as to what goes where. I understand the section prior
> >> to the Modules and Resources section, but I feel like the documentation
> >> makes a quick jump to the section that I'm interested in.
> >> Would I still create my Flask "app" object in the outter-most __init__.py
> >> file, and then use app.register_module from there? And then, in the
> >> __init__.py files inside each Module's directory create the Module objects?
> >> This would leave the views.py file empty, which confuses me a little. Would
> >> I instead leave __init__.py in each Module's directory empty, and create the
> >> Module objects inside the view.py file, then?
> >> I guess I'm just a little confused. Perhaps does anyone have a complete but
> >> simple example on github, or something?
> >> Thank you,
> >> Ryan
> >
> 
> 
> 
> -- 
> "A arrogância é a arma dos fracos."
> 
> ===========================
> Italo Moreira Campelo Maia
> Graduado em Ciência da Computação - UECE
> Desenvolvedor WEB e Desktop (Java, Python, Lua)
> Coordenador do Pug-CE
> -----------------------------------------------------
> http://www.italomaia.com/
> http://twitter.com/italomaia/
> http://eusouolobomau.blogspot.com/
> -----------------------------------------------------
> turtle linux 910 - http://tiny.cc/blogturtle910
> ===========================

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Anton Khodakivskiy
Date:
2010-09-02 @ 09:26
Looks like my last message did not make it to the mailing list, so here it
is again, there was a typo in the repo url. The correct url is below.

http://github.com/akhodakivskiy/flask

On Sep 2, 2010, at 11:22 AM, Anton Khodakivskiy wrote:

> Pardon me, the repo url is 
> http://github.com/akhodakivskiy/flask
> 
> On Sep 2, 2010, at 11:18 AM, Anton Khodakivskiy wrote:
> 
>> Hi , 
>> 
>> I'm pretty new to python and web development, so my experience is not 
overly reliable. 
>> 
>> Here is the flask project that follows the "Larger application" structure:
>> http://github.com/akhodakivskiy/flask/skeleton
>> 
>> $ python runserver.py 
>> and you will have two urls available from different modules:
>> 
>> localhost:5000/
>> localhost:5000/admin
>> 
>> Let me know what you think

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-02 @ 13:48
Hi Anton,

About your skeleton, when you use the __import__ function, don't forget to
specify the fromlist parameter
because without this information, the returned module won't be the named 
module but the top-level module.

Regards,

Stéphane

On 09/02/2010 11:26 AM, Anton Khodakivskiy wrote:
> Looks like my last message did not make it to the mailing list, so here
> it is again, there was a typo in the repo url. The correct url is below.
> 
> http://github.com/akhodakivskiy/flask
> 
> On Sep 2, 2010, at 11:22 AM, Anton Khodakivskiy wrote:
> 
>> Pardon me, the repo url is 
>> http://github.com/akhodakivskiy/flask
>>
>> On Sep 2, 2010, at 11:18 AM, Anton Khodakivskiy wrote:
>>
>>> Hi , 
>>>
>>> I'm pretty new to python and web development, so my experience is not
>>> overly reliable. 
>>>
>>> Here is the flask project that follows the "Larger application"
>>> structure:
>>> http://github.com/akhodakivskiy/flask/skeleton
>>>
>>> $ python runserver.py 
>>> and you will have two urls available from different modules:
>>>
>>> localhost:5000/
>>> localhost:5000/admin
>>>
>>> Let me know what you think

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Armin Ronacher
Date:
2010-09-02 @ 15:40
Hi,

On 2010-09-02 3:48 PM, Stephane Wirtel wrote:
> About your skeleton, when you use the __import__ function, don't
> forget to specify the fromlist parameter because without this
> information, the returned module won't be the named module but
 > the top-level module.
For that the handy "werkzeug.import_string" function exists :)


Regards,
Armin

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-02 @ 15:42
> For that the handy "werkzeug.import_string" function exists :)
Thanks Armin ;)

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Ryan Cole
Date:
2010-09-02 @ 19:04
If I could figure out how to upload my code to github, on Windows, then I'd
show you how I interpreted the documentation for this directory structure.
Mine "works", but I don't think it's very elegant. In fact I feel like the
simplicity that I liked about the smaller setup is entirely lost with the
larger one.

I'll probably switch back to the single views directory setup.

On Thu, Sep 2, 2010 at 10:42 AM, Stephane Wirtel <stephane@wirtel.be> wrote:

> > For that the handy "werkzeug.import_string" function exists :)
> Thanks Armin ;)
>
>
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Anton Khodakivskiy
Date:
2010-09-02 @ 19:17
With well separated module structure you can easily reuse parts of your 
application by just copying one folder, and adding one line of code 
(well... of course you also need to mess with the templates/stylesheets a 
bit).

I actually switched to the larger structure as soon as I figured that 
there at least 3 somewhat independent parts in my application.

On windows use msysgit
http://code.google.com/p/msysgit/

On Sep 2, 2010, at 10:04 PM, Ryan Cole wrote:

> If I could figure out how to upload my code to github, on Windows, then 
I'd show you how I interpreted the documentation for this directory 
structure. Mine "works", but I don't think it's very elegant. In fact I 
feel like the simplicity that I liked about the smaller setup is entirely 
lost with the larger one.
> 
> I'll probably switch back to the single views directory setup.
> 
> On Thu, Sep 2, 2010 at 10:42 AM, Stephane Wirtel <stephane@wirtel.be> wrote:
> > For that the handy "werkzeug.import_string" function exists :)
> Thanks Armin ;)
> 
> 
> 

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Anton Khodakivskiy
Date:
2010-09-02 @ 14:42
Stéphane,

Thanks for the note, I actually run into this problem when I was writing 
this skeleton app. 
But in this case I actually need the top level module, because this module
instantiates the flask.Module object. The views module should be just 
imported in order to ensure that the url handlers are registered.

On Sep 2, 2010, at 4:48 PM, Stephane Wirtel wrote:

> Hi Anton,
> 
> About your skeleton, when you use the __import__ function, don't forget 
to specify the fromlist parameter
> because without this information, the returned module won't be the named
module but the top-level module.
> 
> Regards,
> 
> Stéphane
> 
> On 09/02/2010 11:26 AM, Anton Khodakivskiy wrote:
>> Looks like my last message did not make it to the mailing list, so here
>> it is again, there was a typo in the repo url. The correct url is below.
>> 
>> http://github.com/akhodakivskiy/flask
>> 
>> On Sep 2, 2010, at 11:22 AM, Anton Khodakivskiy wrote:
>> 
>>> Pardon me, the repo url is 
>>> http://github.com/akhodakivskiy/flask
>>> 
>>> On Sep 2, 2010, at 11:18 AM, Anton Khodakivskiy wrote:
>>> 
>>>> Hi , 
>>>> 
>>>> I'm pretty new to python and web development, so my experience is not
>>>> overly reliable. 
>>>> 
>>>> Here is the flask project that follows the "Larger application"
>>>> structure:
>>>> http://github.com/akhodakivskiy/flask/skeleton
>>>> 
>>>> $ python runserver.py 
>>>> and you will have two urls available from different modules:
>>>> 
>>>> localhost:5000/
>>>> localhost:5000/admin
>>>> 
>>>> Let me know what you think
> 

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-02 @ 14:45
In my case, I use that to load each modules.

MODULES = [
    ('general', '/'),
    ('admin', '/admin'),
    ('blog', '/blog'),
    ('lead', '/lead'),
    ('wine', '/wine'),
    ('tasting', '/tasting'),
    ('forum', '/formum'),
    ('event', '/event')
]

for module_name, url_prefix in MODULES:
    app.register_module(__import__('caviste.views.%s' % module_name, 
fromlist=['module']).module, url_prefix=url_prefix)

I use a basic structure, with one "views" directory and my modules into 
this directory.

I think I will change to the "Larger Applications" structure.

I propose to create a snippet on the website.

Regards,


On 09/02/2010 04:42 PM, Anton Khodakivskiy wrote:
> Stéphane,
> 
> Thanks for the note, I actually run into this problem when I was writing
this skeleton app. 
> But in this case I actually need the top level module, because this 
module instantiates the flask.Module object. The views module should be 
just imported in order to ensure that the url handlers are registered.
> 
> On Sep 2, 2010, at 4:48 PM, Stephane Wirtel wrote:
> 
>> Hi Anton,
>>
>> About your skeleton, when you use the __import__ function, don't forget
to specify the fromlist parameter
>> because without this information, the returned module won't be the 
named module but the top-level module.
>>
>> Regards,
>>
>> Stéphane
>>
>> On 09/02/2010 11:26 AM, Anton Khodakivskiy wrote:
>>> Looks like my last message did not make it to the mailing list, so here
>>> it is again, there was a typo in the repo url. The correct url is below.
>>>
>>> http://github.com/akhodakivskiy/flask
>>>
>>> On Sep 2, 2010, at 11:22 AM, Anton Khodakivskiy wrote:
>>>
>>>> Pardon me, the repo url is 
>>>> http://github.com/akhodakivskiy/flask
>>>>
>>>> On Sep 2, 2010, at 11:18 AM, Anton Khodakivskiy wrote:
>>>>
>>>>> Hi , 
>>>>>
>>>>> I'm pretty new to python and web development, so my experience is not
>>>>> overly reliable. 
>>>>>
>>>>> Here is the flask project that follows the "Larger application"
>>>>> structure:
>>>>> http://github.com/akhodakivskiy/flask/skeleton
>>>>>
>>>>> $ python runserver.py 
>>>>> and you will have two urls available from different modules:
>>>>>
>>>>> localhost:5000/
>>>>> localhost:5000/admin
>>>>>
>>>>> Let me know what you think
>>
> 

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Stephane Wirtel
Date:
2010-09-02 @ 12:54
Hi Anton,

I like your skeleton, you use a module variable in your modules. Very useful.

Great !

Thanks

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
bruce bushby
Date:
2010-09-02 @ 13:47
It would be nice to agree on the "best flask practice" skeleton "as endorsed
by flask developers" so that...like python...all flask apps are laid out in
the same and a complete stranger can take a flask app and get going with
little effort.

From what I've seen its almost there.....perhaps that "deploy flask app
script" would help enforce good practices.

Bruce


On Thu, Sep 2, 2010 at 1:54 PM, Stephane Wirtel <stephane@wirtel.be> wrote:

> Hi Anton,
>
> I like your skeleton, you use a module variable in your modules. Very
> useful.
>
> Great !
>
> Thanks
>

Re: [flask] Larger Applications, I'm trying to achieve this directory structure

From:
Italo Maia
Date:
2010-09-02 @ 07:35
ps: the structure in
http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources works
pretty well, with statics and templates being served as they should.

pss: if you're going to do something "larger", you gonna miss a admin
interface like hell.

2010/9/2 Italo Maia <italo.maia@gmail.com>

> Ryan, the "large application" directory structure is achievable. Create a
> apps/ directory in the project root. Throw a __init__.py there. Create a
> views.py file in these directories and, inside them, create an app module
> like:
>
> from flask import Module
> app = Module(__name__, 'app_name', url_prefix='/prefix')
>
> then register your views with this module.
>
> In the project root directory, create something like main.py and
> instantiate your Flask app there.
>
> # this goes in the main.py file
> from flask import Flask
> app = Flask()
>
> Create your project factory as written in docs then register all the app
> modules within yout Flask instance. You could use some tricks here.
> Something like:
>
> # create a list with the app names
> installed_apps = ['app_x', 'app_y', 'app_z']
>
> then load the app object from the views module in each app using the
> __import__ then register the modules with yout Flask instance.
>
> Something like:
>
> for app_name in installed_apps:
> module = __import__('apps.%s.views', fromlist=['app'])
> # app is a flask instance here, not a module
> app.register_module(module.app)
>
> You could add some hasattr here and there, but this is pretty much it. Hope
> that helped! I've been trying some stuff with flask and that worked for me.
>
> 2010/9/2 Thadeus Burgess <thadeusb@thadeusb.com>
>
> Those don't really follow that same structure. They don't help at all
>> in exploring that application layout.
>>
>> For some reason I don't think the layout that is mentioned in the docs
>> is even possible. It looks like Armin just threw that in the docs at
>> the last minute but its not a actual valid application structure.
>>
>> --
>> Thadeus
>>
>>
>>
>>
>>
>> On Thu, Sep 2, 2010 at 1:57 AM, Dan Jacob <danjac354@gmail.com> wrote:
>> > https://bitbucket.org/danjac/newsmeme/
>> > http://github.com/mitsuhiko/flask/tree/website
>> >
>> > On 2 September 2010 01:29, Ryan Cole <betawarz@gmail.com> wrote:
>> >> Hi all,
>> >> I'm trying to achieve the directory structure mentioned very briefly at
>> the
>> >> end of the packages documentation. The direct permalink is
>> >> here:
>> http://flask.pocoo.org/docs/patterns/packages/#modules-and-resources
>> >> I'm a little confused as to what goes where. I understand the section
>> prior
>> >> to the Modules and Resources section, but I feel like the documentation
>> >> makes a quick jump to the section that I'm interested in.
>> >> Would I still create my Flask "app" object in the outter-most
>> __init__.py
>> >> file, and then use app.register_module from there? And then, in the
>> >> __init__.py files inside each Module's directory create the Module
>> objects?
>> >> This would leave the views.py file empty, which confuses me a little.
>> Would
>> >> I instead leave __init__.py in each Module's directory empty, and
>> create the
>> >> Module objects inside the view.py file, then?
>> >> I guess I'm just a little confused. Perhaps does anyone have a complete
>> but
>> >> simple example on github, or something?
>> >> Thank you,
>> >> Ryan
>> >
>>
>
>
>
> --
> "A arrogância é a arma dos fracos."
>
> ===========================
> Italo Moreira Campelo Maia
> Graduado em Ciência da Computação - UECE
> Desenvolvedor WEB e Desktop (Java, Python, Lua)
> Coordenador do Pug-CE
> -----------------------------------------------------
> http://www.italomaia.com/
> http://twitter.com/italomaia/
> http://eusouolobomau.blogspot.com/
> -----------------------------------------------------
> turtle linux 910 - http://tiny.cc/blogturtle910
> ===========================
>



-- 
"A arrogância é a arma dos fracos."

===========================
Italo Moreira Campelo Maia
Graduado em Ciência da Computação - UECE
Desenvolvedor WEB e Desktop (Java, Python, Lua)
Coordenador do Pug-CE
-----------------------------------------------------
http://www.italomaia.com/
http://twitter.com/italomaia/
http://eusouolobomau.blogspot.com/
-----------------------------------------------------
turtle linux 910 - http://tiny.cc/blogturtle910
===========================