Heroku's Advantages Over Google App Engine
Pros:- Postgres (you can even use pgAdmin to view your database)
- Uses Git to push your application into production
- More monitoring features and 3rd party apps
- As long as your project uses one dyno, it runs for free (similar to google, but with a less confusing billing structure)
- 10k row limit for your database before they start charging you $9 per month
AttributeError: 'QuerySelectField' object has no attribute '_sa_instance_state'
I came across this error when I was trying to make a custom validator in Flask-Admin with wtforms form objects.This code didn't work:
def location_must_not_conflict(form, field):
if Event.query.filter(Event.location == form.location).first():
raise wtforms.validators.ValidationError('Location conflicts with another request for the same venue.')
Because I was using form.location and not form.location.data.
This will work:
def location_must_not_conflict(form, field):
if Event.query.filter(Event.location == form.location.data).first():
raise wtforms.validators.ValidationError('Location conflicts with another request for the same venue.')
Individual Form Fields In Jinja2 - Flask-Admin
On your edit and create templates in Flask-Admin, you can print individual form fields like this (the field's name is location):Google Calendar Api bad request 400 - Python Authomatic Library
I was finally able to get the request to go through by adding a header saying it's json format. Here's an example:requestbody = """
{
"end": {
"dateTime": "2014-05-18T01:35:00Z"
},
"start": {
"dateTime": "2014-05-18T01:35:00Z"
},
"description": "test2",
"location": "test venue",
"summary": "test2"
}
Add user_id for modified_by field before save - Flask-Admin
In Flask-Admin, you can override the "on_model_change" function to to automatically populate a "modified_by" field in your model.
class LocationView(ModelView):
def on_model_change(self, form, model):
model.user_id = g.user.id
admin = Admin(app)
admin.add_view(LocationView(Location, db.session, name="Locations"))
Favorite Flask Boilerplate/Skeleton/Templates
- https://github.com/sloria/cookiecutter-flask
- https://github.com/mattupstate/overholt
- Because it's easy: https://github.com/fogleman/HelloFlask
Those do a lot of the work of starting a new Flask project for you.
With cookiecutter flask, all you need to do to build a new project is: cookiecutter https://github.com/sloria/cookiecutter-flask.git
As a warning, cookiecutter flask and overholt include a lot of stuff. I ended up not using it because it was too much work to change everything to work with oAuth.
Remove Index Column From Pandas CSV Export
http://stackoverflow.com/a/19782137/1364191Reverse PDF Page Order
I created an app that allows you to upload a pdf and it returns a copy of your PDF with the page order reversed. The code is here: https://github.com/pawl/pdfreverse
Initially when I googled how to do this in Adobe Acrobat, the first few results had fairly complicated solutions. After I made the app, I ended up finding an easier way to do it in Adobe (in the 6th from the top Google result on “reverse pdf order acrobat”…):

Oh well, it was a fun project.
Discourse As Potential Mailing List Replacement
While tested out Discourse, I only found a few negative things:
- To make it act like a mailing list, it currently requires each user to change settings on their account: https://github.com/discourse/discourse/blob/master/docs/MAILING-LIST-SETUP.md#suggested-user-preferences
I commented on a thread about a new feature that allows setting defaults for this: https://meta.discourse.org/t/default-email-settings-for-a-new-user/14980 - It doesn’t allow setting defaults for which categories the user has “Watched”. For example, I would want to default the “General” list to “Watched”, but more obscure lists would only be watched if the user chooses to.
- It uses a different e-mail address for each e-mail it sends you (this is to keep track of which thread it belongs to), here’s an example of a “From” address: testdiscourse+43854630fb3a3d9492505fa5a23db196@gmail.com
Google Groups always has the same to/from e-mail address and magically figures this out. This might be weird in some peoples’ email clients.
As a forum, this beats the crap out of PhpBB, but as a mailing list it’s not a clear winner over Google Groups yet. It’s open source, has a better web interface, and the “Categories” are a cool feature for keeping all the lists in the same place. But, the “email in” functionality was too recently implemented, and it might take a few months before it’s as polished as Google Groups.
It’s going to be a very tempting replacement if they add default settings for user preferences.
Screenshots:




