Live data from Hacker News

Flask 0.7 Released (Python Web Framework)

flask.pocoo.org

41–50 of 80 posts

Re: Flask 0.7 Released (Python Web Framework)

#41
post #39

Right now, I'm writing most of my projects in Tornado.. Not because I need the async, but because I wanted a simple web.py like format that was under active development. Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? I can understand the simplicity argument; I chose to avoid Django because it was t…

Tornado is batteries included. Flask uses Werkzeug and Jinja2 and encourages packaging extensions for localization, form processing, ORM's etc.. Flask, Werkzeug and Jinja2 are all Pocoo projects that have a good community around them and excellent documentation. Technically I would not like to argue the superiority of either, although Flask seems to fit my tastes much better.

Flask's use and deployment of "magic" is pretty spot on. For example by making the request object omnipresent (that is flask.request is always bound and has the right context). That way it is not passed around the MVC stack but just imported and introspected when needed.

Flask is probably the "healthiest" project I've encountered.

Re: Flask 0.7 Released (Python Web Framework)

#42

I'm always impressed by Flask - especially its documentation. In fact, this seems like a good occasion to have a poke around and build something with it. On a slightly related note - although jinja2 is already quite compact, I'm a fan of haml and I'm always surprised by the lack of support for it in Python. Is there something I'm missing? Uncanny valley for Pythonistas?

There's hamlish-jinja which is a preprocessor for haml-like[1] syntax for Jinja.

The project with the most traction seems to be HamlPy[2], but it's limited to Django templates.

The only generic implementation of Haml in Python that I'm aware of is PyHAML[3], but I have never used it.

[1] https://github.com/Pitmairen/hamlish-jinja [2] https://github.com/jessemiller/HamlPy [3] https://github.com/mikeboers/PyHAML

Re: Flask 0.7 Released (Python Web Framework)

#43
post #39

Right now, I'm writing most of my projects in Tornado.. Not because I need the async, but because I wanted a simple web.py like format that was under active development. Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? I can understand the simplicity argument; I chose to avoid Django because it was t…

Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use?

Pretty much yes to all of this.

I can understand the simplicity argument; I chose to avoid Django because it was too heavy, so I'd love to hear more about how Flask compares.

Flask "feels" more like CherryPy than Django to me, but yes, it's more lightweight than Django and more modular (doesn't define an ORM, etc).

The thing that keeps me from using Flask for any serious work is Django's admin interface. That thing saves me ridiculous amounts of time.

Re: Flask 0.7 Released (Python Web Framework)

#44

I take the occasion to ask here if someone could point or write some documentation on unittest in Flask. I am trying to get that right using mongodb...

http://flask.pocoo.org/docs/testing/

For testing a MongoDB database, I wrote a simple unittest.TestCase subclass that in the setUp and tearDown, creates and then deletes a test database.

Re: Flask 0.7 Released (Python Web Framework)

#45

I take the occasion to ask here if someone could point or write some documentation on unittest in Flask. I am trying to get that right using mongodb...

http://flask.pocoo.org/docs/testing/ For testing a MongoDB database, I wrote a simple unittest.TestCase subclass that in the setUp and tearDown, creates and then deletes a test database.

Could you put an example on pastebin or somewhere? I would really appreciate this.

Re: Flask 0.7 Released (Python Web Framework)

#46
post #39

Right now, I'm writing most of my projects in Tornado.. Not because I need the async, but because I wanted a simple web.py like format that was under active development. Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? I can understand the simplicity argument; I chose to avoid Django because it was t…

Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? Pretty much yes to all of this. I can understand the simplicity argument; I chose to avoid Django because it was too heavy, so I'd love to hear more about how Flask compares. Flask "feels" more like CherryPy than Django to me, but yes, it's more lightw…

Couldn't you use inspectdb to introspect your Flask database and use Django's admin that way? You'd have to remember to do it every time you changed your database; but it'd probably get you most of the way there.

Re: Flask 0.7 Released (Python Web Framework)

#47
post #14

Earlier quoted context omitted.

I would describe it more carefully. Bottle's advantage that it's self contained and in a single file, however bottle's design also hides away the application object from you which makes it quite hard to have more than one of them. It is possible with the stacked object thing and I think they changed it even to make it possible to do what Flask did, but when Flask started at least there was a design difference there.…

Any reasons why they should merge if they are so different?

Merge is an excellent idea when two projects, frameworks, etc have the same goals (Not necessarily the same features). For example The Pylons Project taking BFG as is base and making Pyramid, with all the experience from Pylons community and BFG. This will make changes on both sides of the community but brings a new Framework with the possibility of improvement. I guess the idea is take the best from both frameworks y make a new one, better, with a big community, and a lot of knowledge from the previous experiences.

Re: Flask 0.7 Released (Python Web Framework)

#48

Earlier quoted context omitted.

http://flask.pocoo.org/docs/testing/ For testing a MongoDB database, I wrote a simple unittest.TestCase subclass that in the setUp and tearDown, creates and then deletes a test database.

Could you put an example on pastebin or somewhere? I would really appreciate this.

Along the lines of http://flask.pocoo.org/docs/patterns/mongokit/, I have a MONGODB_DATABASE setting, which is set to my normal database name. Then access the database via the connections' dictionary syntax, instead of attribute syntax (I have a helper method to make this prettier):

  connection[app.config['MONGODB_DATABASE']].mycollection.find_one()

The unittest code just modifies the setting:

  import unittest
  def setUp(self):
    myapp.app.config['MONGODB_DATABASE'] = 'test'
    self.app = myapp.app.test_client()

  def tearDown(self):
    # can clean up here, e.g.
    connection.test.drop_collection('mycollection')

Re: Flask 0.7 Released (Python Web Framework)

#49

I'm always impressed by Flask - especially its documentation. In fact, this seems like a good occasion to have a poke around and build something with it. On a slightly related note - although jinja2 is already quite compact, I'm a fan of haml and I'm always surprised by the lack of support for it in Python. Is there something I'm missing? Uncanny valley for Pythonistas?

There's a Nemo[1] a "pythonic haml". It doesn't follow the Haml spec exactly, but rather tries to take the good parts and apply them to something suitable for Pythonistas.

It's built over Mako templates, so its faster and far more flexible than one built against the Django template markup.

[1] https://github.com/9cloud/Nemo

Re: Flask 0.7 Released (Python Web Framework)

#50
post #46

Earlier quoted context omitted.

Can someone help me understand where Flask fits into things? It would essentially be a replacement for Tornado? What's the advantage of this over Tornado? Ease of use? Pretty much yes to all of this. I can understand the simplicity argument; I chose to avoid Django because it was too heavy, so I'd love to hear more about how Flask compares. Flask "feels" more like CherryPy than Django to me, but yes, it's more lightw…

Couldn't you use inspectdb to introspect your Flask database and use Django's admin that way? You'd have to remember to do it every time you changed your database; but it'd probably get you most of the way there.

>You'd have to remember to do it every time you changed your database;

That's probably why he just finds it easier to use django.

Post reply on HN