librelist archives

« back to archive

Project generator

Project generator

From:
LeafStorm
Date:
2010-09-14 @ 01:03
Hi,

Recently (I can't find exactly where) someone mentioned Paste Script for 
generating project templates. It might be a good idea to start 
developing something like paster that does project templating. (I don't 
think using paster is a Flask-friendly solution since [1] it's related 
to Paste and [2] it uses arcane setuptools features.)

Ideally, this would be completely independent from Flask or any other 
Web framework type thing. The layout of a template itself would probably 
be something similar to Paste, where you have a Template class that 
lives in a package somewhere and its sources are read from a folder in 
the same package.

# flaskext/templates/app.py

from generator import Template, OptionsError
from generator.utils import valid_identifier

class FlaskTemplate(Template):
     name = "Flask application"
     sources = "app_template"    # copy from templates/app_template
     summary = "Creates a skeleton Flask app"

     def before(self):
         if 'package' not in self.options:
             if not valid_identifier(self.target.basename):
                 raise OptionsError("target is not a valid package name")
             self.context['package'] = self.target.basename
template = FlaskTemplate

And the flaskext/templates/app_template folder might look like:

README
+package+/
   __init__.py_t
   utils.py_t
   views/
     .empty
   templates/
     .empty
   static/
     .empty

Or something like that. You would run "generator flaskext.templates.app 
DESTINATION" and it would copy that. (The "_t" indicates "template". Not 
sure what template language to actually use.) You can also use 
"extension templates", as it generates a metadata file indicating what 
it was generating from, so if there was a flaskext.templates.module 
extension template you could just do "generator module". What does 
everyone think about this?
-- 
Regards, Matthew "LeafStorm" Frazier
http://leafstorm.us/

Re: [flask] Project generator

From:
kevin beckford
Date:
2010-09-14 @ 04:34
> Recently (I can't find exactly where) someone mentioned Paste Script for
> generating project templates. It might be a good idea to start
> developing something like paster that does project templating. (I don't
> think using paster is a Flask-friendly solution since [1] it's related
> to Paste and [2] it uses arcane setuptools features.)

I don't understand.  People use PasteScript for all  sorts of things.
It works, right now.  Flask is a microframework, no?   Is there a
licensing issue or something?  Why can it not be related to Paste?

From the docs :  " There is database abstraction layer, no form
validation or anything else where different libraries already exist
that can handle that."

Which arcane features are you referring to, from setuptools/distribute?

Re: [flask] Project generator

From:
Dan Jacob
Date:
2010-09-14 @ 08:00
I actually started something like this some time ago for Werkzeug and
SQLAlchemy, which I abandoned when Flask came along.

https://bitbucket.org/danjac/satchel

Paste indeed works quite well for this, and (once you get used to its
tricki) integrates nicely with pip etc : you can have templates in
PyPi, install them and they will be added to your local list of
templates.

We need to be careful not to be Flask-specific for the sake of it,
when there are proven tools that do the trick. In a similar vein if we
come up with something better, then if possible make it a generic
tool, not just something for Flask apps.

On 14 September 2010 05:34, kevin beckford <chiggsy@lazyweb.ca> wrote:
>> Recently (I can't find exactly where) someone mentioned Paste Script for
>> generating project templates. It might be a good idea to start
>> developing something like paster that does project templating. (I don't
>> think using paster is a Flask-friendly solution since [1] it's related
>> to Paste and [2] it uses arcane setuptools features.)
>
> I don't understand.  People use PasteScript for all  sorts of things.
> It works, right now.  Flask is a microframework, no?   Is there a
> licensing issue or something?  Why can it not be related to Paste?
>
> >From the docs :  " There is database abstraction layer, no form
> validation or anything else where different libraries already exist
> that can handle that."
>
> Which arcane features are you referring to, from setuptools/distribute?
>

Re: [flask] Project generator

From:
Ali Afshar
Date:
2010-09-14 @ 10:16
Sorry to go on about this, it is one of my pet topics, and you even
allude to it. These project generators are dangerous, and really are
the reason Flask even exists. The problem is this, when the generated
code must change, eg a bug:

1. Fix the generator
2. Fix all the generated code independently

Which is a lot of work versus updating a single library/framework version.

Having said that, there would be some use in something that just did
mkdir and touch, but I think we should always find a good balance
between features that should be in the library (Flask) and features
that are generated by the generator. It's a hard balance though, and
one that Pylons (imho) has got wrong with paste. But then Pylons isn't
as good as Flask so...


On 14 September 2010 09:00, Dan Jacob <danjac354@gmail.com> wrote:
> I actually started something like this some time ago for Werkzeug and
> SQLAlchemy, which I abandoned when Flask came along.
>
> https://bitbucket.org/danjac/satchel
>
> Paste indeed works quite well for this, and (once you get used to its
> tricki) integrates nicely with pip etc : you can have templates in
> PyPi, install them and they will be added to your local list of
> templates.
>
> We need to be careful not to be Flask-specific for the sake of it,
> when there are proven tools that do the trick. In a similar vein if we
> come up with something better, then if possible make it a generic
> tool, not just something for Flask apps.
>
> On 14 September 2010 05:34, kevin beckford <chiggsy@lazyweb.ca> wrote:
>>> Recently (I can't find exactly where) someone mentioned Paste Script for
>>> generating project templates. It might be a good idea to start
>>> developing something like paster that does project templating. (I don't
>>> think using paster is a Flask-friendly solution since [1] it's related
>>> to Paste and [2] it uses arcane setuptools features.)
>>
>> I don't understand.  People use PasteScript for all  sorts of things.
>> It works, right now.  Flask is a microframework, no?   Is there a
>> licensing issue or something?  Why can it not be related to Paste?
>>
>> >From the docs :  " There is database abstraction layer, no form
>> validation or anything else where different libraries already exist
>> that can handle that."
>>
>> Which arcane features are you referring to, from setuptools/distribute?
>>
>

Re: [flask] Project generator

From:
Armin Ronacher
Date:
2010-09-14 @ 11:00
Hi,

On 2010-09-14 12:16 PM, Ali Afshar wrote:
> Sorry to go on about this, it is one of my pet topics, and you even
> allude to it. These project generators are dangerous, and really are
> the reason Flask even exists.
Ack.  However what I think might be useful is something that just 
generates a folder with a package and an __init__.py that creates a 
flask application object and a useful setup.py and MANIFEST.in.

I am currently copy/pasting them from existing projects all the time 
which sounds stupid.  I suppose there could be a generator on 
flask.pocoo.org for that that produces a zipfile.


Regards,
Armin

Re: [flask] Project generator

From:
Ali Afshar
Date:
2010-09-14 @ 11:22
On 14 September 2010 12:00, Armin Ronacher <armin.ronacher@active-4.com> wrote:
> Hi,
>
> On 2010-09-14 12:16 PM, Ali Afshar wrote:
>> Sorry to go on about this, it is one of my pet topics, and you even
>> allude to it. These project generators are dangerous, and really are
>> the reason Flask even exists.
> Ack.  However what I think might be useful is something that just
> generates a folder with a package and an __init__.py that creates a
> flask application object and a useful setup.py and MANIFEST.in.
>
> I am currently copy/pasting them from existing projects all the time
> which sounds stupid.  I suppose there could be a generator on
> flask.pocoo.org for that that produces a zipfile.

I agree, saving the copy-paste is worth it. I am just always wary it
doesn't go too far, and I am sure it won't.

Re: [flask] Project generator

From:
Alex
Date:
2010-09-14 @ 12:08
On Tue, Sep 14, 2010 at 1:22 PM, Ali Afshar <aafshar@gmail.com> wrote:
> On 14 September 2010 12:00, Armin Ronacher <armin.ronacher@active-4.com> wrote:
>> Hi,
>>
>> On 2010-09-14 12:16 PM, Ali Afshar wrote:
>>> Sorry to go on about this, it is one of my pet topics, and you even
>>> allude to it. These project generators are dangerous, and really are
>>> the reason Flask even exists.
>> Ack.  However what I think might be useful is something that just
>> generates a folder with a package and an __init__.py that creates a
>> flask application object and a useful setup.py and MANIFEST.in.
+1

Alex

Re: [flask] Project generator

From:
kevin beckford
Date:
2010-09-14 @ 15:25
Ack.  However what I think might be useful is something that just
>> generates a folder with a package and an __init__.py that creates a
>> flask application object and a useful setup.py and MANIFEST.in.

Agreed.  I can always Paste it up later.

Re: [flask] Project generator

From:
Dan Jacob
Date:
2010-09-14 @ 10:21
I use a generator for my own projects, but I agree with the problems -
every time you change something in the template you have to change the
generated code. It's handy for some cases as a convenience but I don't
think it should ever be part of any Flask core functionality.

That said, if you want a generator, it's better to use an
off-the-shelf, proven one (Paste) than reinvent the wheel.

On 14 September 2010 11:16, Ali Afshar <aafshar@gmail.com> wrote:
> Sorry to go on about this, it is one of my pet topics, and you even
> allude to it. These project generators are dangerous, and really are
> the reason Flask even exists. The problem is this, when the generated
> code must change, eg a bug:
>
> 1. Fix the generator
> 2. Fix all the generated code independently
>
> Which is a lot of work versus updating a single library/framework version.
>
> Having said that, there would be some use in something that just did
> mkdir and touch, but I think we should always find a good balance
> between features that should be in the library (Flask) and features
> that are generated by the generator. It's a hard balance though, and
> one that Pylons (imho) has got wrong with paste. But then Pylons isn't
> as good as Flask so...
>
>
> On 14 September 2010 09:00, Dan Jacob <danjac354@gmail.com> wrote:
>> I actually started something like this some time ago for Werkzeug and
>> SQLAlchemy, which I abandoned when Flask came along.
>>
>> https://bitbucket.org/danjac/satchel
>>
>> Paste indeed works quite well for this, and (once you get used to its
>> tricki) integrates nicely with pip etc : you can have templates in
>> PyPi, install them and they will be added to your local list of
>> templates.
>>
>> We need to be careful not to be Flask-specific for the sake of it,
>> when there are proven tools that do the trick. In a similar vein if we
>> come up with something better, then if possible make it a generic
>> tool, not just something for Flask apps.
>>
>> On 14 September 2010 05:34, kevin beckford <chiggsy@lazyweb.ca> wrote:
>>>> Recently (I can't find exactly where) someone mentioned Paste Script for
>>>> generating project templates. It might be a good idea to start
>>>> developing something like paster that does project templating. (I don't
>>>> think using paster is a Flask-friendly solution since [1] it's related
>>>> to Paste and [2] it uses arcane setuptools features.)
>>>
>>> I don't understand.  People use PasteScript for all  sorts of things.
>>> It works, right now.  Flask is a microframework, no?   Is there a
>>> licensing issue or something?  Why can it not be related to Paste?
>>>
>>> >From the docs :  " There is database abstraction layer, no form
>>> validation or anything else where different libraries already exist
>>> that can handle that."
>>>
>>> Which arcane features are you referring to, from setuptools/distribute?
>>>
>>
>

Re: [flask] Project generator

From:
Dan Jacob
Date:
2010-09-14 @ 08:01
>
> Paste indeed works quite well for this, and (once you get used to its
> tricki) integrates nicely with pip etc : you can have templates in

Sorry, once you get used to its trickiness (entry points etc).

> PyPi, install them and they will be added to your local list of
> templates.
>
> We need to be careful not to be Flask-specific for the sake of it,
> when there are proven tools that do the trick. In a similar vein if we
> come up with something better, then if possible make it a generic
> tool, not just something for Flask apps.
>
> On 14 September 2010 05:34, kevin beckford <chiggsy@lazyweb.ca> wrote:
>>> Recently (I can't find exactly where) someone mentioned Paste Script for
>>> generating project templates. It might be a good idea to start
>>> developing something like paster that does project templating. (I don't
>>> think using paster is a Flask-friendly solution since [1] it's related
>>> to Paste and [2] it uses arcane setuptools features.)
>>
>> I don't understand.  People use PasteScript for all  sorts of things.
>> It works, right now.  Flask is a microframework, no?   Is there a
>> licensing issue or something?  Why can it not be related to Paste?
>>
>> >From the docs :  " There is database abstraction layer, no form
>> validation or anything else where different libraries already exist
>> that can handle that."
>>
>> Which arcane features are you referring to, from setuptools/distribute?
>>
>