I'm writing a book on Flask, the Python web framework
robert.io
robert.io
What I see as being a useful book on Flask:
1) listing and naming common stable plugins (flask-security, flask-login) and how they integrate and work together. There's a good page on the Flask site, but I feel a lot of the plug-ins don't work particularly well together. There's tons of different authentication librarys (especially when dealing with OAuth) that work with varying degree out there. Some guidance around this would be really useful.
2) Different ways to setup a large project. How to structure folders, etc. There's some good topics on StackOverflow about this, but my experience trying to integrate different plug-ins, etc, leads to a more messy solution. Maybe some ideas in abstracting out data access.
3) The Art of building up your tech stack with lego bricks. Choosing which plug-ins to use.
4) Testing patterns.
5) More of a style of "I'm trying to do this", this is how you do it. (Note: there's lots of great questions and solutions on the email list that could/should be culled for ideas and consolidated)
6) Debugging and tracing through 3rd party flask-plugins. This is a huge problem for me as most don't include log comments
7) Writing and structuring a good plug-in/blueprint, with some examples of different ways to include reusable code into the project.
Note: I've co-authored a book in the past that was published by Wiley and I think your schedule is pretty optimistic, especially considering you've still got some learning and research to do. Unless, you're just regurgitating the already pretty in-depth documentation.
Second Note: I'm just reading the O'Reily book on Angular.JS, it's less that 200 pages. It's dense with ideas and explanations on WHY something is. This makes it extremely useful. I really like books that focus on the WHY, because the HOW because much simpler to comprehend. I also appreciate the book because it's not some 600 page tome of regurgitated documentation.
1) offer guidance on making appropriate configuration guidelines
2) suggestions on how to structure a plugin so the view templates can be easily customized or overwritten. Same with the route logic. Same with the controller.
3) decoupling code with signals and blinker.
Generally, how to make a plug-in that provides enough hooks so someone using it doesn't just have to fork their own code off of it.
Curious (and no experience web dev-ing here), why not? Flask and Bottle seem "minimalist", which in my thought process means less stuff to worry about to start simple apps in.
This logic could of course be upside down - less framework = more code to write?
Django looked too confusing! :-)
Flask's main API is heavily based on decorators, and those are a perennial problem for new programmers.
Flask is like Legos in that you choose the pieces to build onto its minimalist stack. You can use if for lightweight prototyping or full-blown web apps.
Since all these things "are a worry", it's probably best for new-comers to web dev to use a full stack that makes decisions for you, that has cohesive documentation across components, and a large contingent of users.
Very well said.
"best for new-comers to web dev to use a full stack that makes decisions for you"
I do not agree. When I started learning web dev. using python, I started with Django. As I moved along trying to hack a simple side project using django, I realized that I was just not understanding the "why" of many things. For example, I tried to create a simple user registration and needed my own fields on the user object. Playing around with User and User_Profile on django, I gave up after a few hours. When I came across Flask, I actually found it easier to do some of my own stuff to understand the whys and then i could always choose a vetted extension/plugin. For example, I wrote my own login system in flask and then switched to Flask-Login later. Btw, this is not about django vs flask but just giving a perspective as a newbie learner.
To newbies, my personal opinion is to understand the "whys" a lot more than just the "what". I actually think that flask is a better way to start learning because it will force you to think about the basics like sessions, user management etc. The more you learn why something works the way it works, the better you will become at it.
The same goes for all of the plugins. You only have to add (and therefore learn about) the "legos" -- to use taude's metaphor -- that you need to build your spaceship.
Regarding the schedule, since I've gotten I few comments on this I'm starting to think it might have a little weight to it. I'm pretty determined to get it done by that launch date, but my primary concern is writing a really good book. If I must delay launch, I'd rather do that than rush it.
I really like the idea of explaining the "Why?" Do you mean explaining why certain practices are preferable, or why the creators of plugins and Flask itself did certain things?
Also, your notes are all amazing and I'll be referring to them as I outline the book!
For example, I use jsonp and I use a decorator from the Flask snippets (http://stackoverflow.com/questions/16134164/jquery-ajax-json...), however, I have no idea how this works and why jsonp is better than json...
Then I would like the book to link these learning to building secure and well tested web applications.
The reasons why I would pay for this are: 1. I would like to build a spreadsheets sharing app but I am very scared of handling sensible data if I don't know very well (by very well I mean the source code) my tech stack and also I know little about web security 2. I would like to contribute to Flask development one day (because it's cool, let' be honest) 3. It takes too much time for me to find out these things on my own and I would gladly pay for the time I save with a book
It is something that I'll keep in mind in writing, but I think it might be better for another project.
> I have June and July to write, edit, market, and launch
> the book. It may be slightly ambitious, but I plan to
> have a lot of time on my hands.
That'd be an absurdly demanding schedule for an experienced author and seasoned web programmer. Good luck; regardless of what comes out of it, it's a decent exercise.At least that's what I'm telling myself. I know Sacha Grief published his book in something like three weeks, though it was shorter than what I'm going for and he's more experienced with his topic.
Nonetheless, you're right that regardless of what comes out of it, it'll be a decent exercise.
But do set a new target date if you miss your original one. Having a big red circle on the calendar can be an amazing motivator, even if there's no consequences for missing it.
Good luck!
- sqlalchemy integration by "hand" (not using flask-sqlalchemy module) : managing sqlalchmey session scope and lifecycle "in the middle" of the flask request lifecycle
- celery integration "by hand" : flask app configuration reuse by celery tasks.
- google app engine deployment
- uwsgi + nginx deployment
- user credential + session management.
+ a chapter on good REST JSON API architecture (eg : returning both HTTP error code along with JSON data).
Now i've got celery tasks, and they're also using sqlalchemy, and all of the sudden, my celery tasks running on the same thread seem to keep the same session object for different tasks.
One solution (IIRC) was to create a new "fake" request context for each task, and then let sqlalchemy session bind to that fake request.
If i just plugged the flask-sqlalchemy module, i wouldn't have even known about session scopes, and would have looked at the celery bug with a blank stare.
Since flask is a micro framework it lets you customize those kind of things. But more importantly, it lets you LEARN about the issues in the first place. I think that's one of the major benefits of dealing with micro frameworks.
Don't get me wrong, Flask seems to have a lot of mind-share, it just seems like a lot of people would be interested in working with Python 3.
Personally I am in no hurry to switch to Python 3 and Flask "just works" and does everything I need in a, at least for me, sane way.
[1] http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/
Edit: they = Flask and some dependencies
I used and played with bottle first, and seriously thought about it for implementing my restful-ish APIs.
When I was starting, my first thought (like most people) was to work with Django, but what drove me crazy was that my project started with a bunch of files and code that I didn't write. I want all of that to be abstracted away via plugins and modules, and Flask does that really well.
I'm not sure how that compares to Bottle or other Python frameworks, but I feel like Flask suits me perfectly.
Regarding Python 3 support, a port is in progress so as Python 3 gains traction I think Flask will emerge as part of that transition, but for now Python 2 works well for most people.
I haven't done much Python web development before, but I have a fair amount of experience with PHP and Ruby, so I found stitching together something useful with Bottle and a number of other packages was pretty low-friction other than porting a half-dozen different packages to Python 3. Unfortunately looking at flask it seemed the work to port it along with jinja2 and werkzeug was too much of a barrier to entry.
[1] http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/