I hereby claim:
- I am jmagnusson on github.
- I am jacobsvante (https://keybase.io/jacobsvante) on keybase.
- I have a public key whose fingerprint is 872D C648 5739 1BD4 EDA4 AAA8 15BB 07D8 AB57 29C0
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(This gist is pretty old; I've written up my current approach to the Pyramid integration on this blog post, but that blog post doesn't go into the transactional management, so you may still find this useful.)
I've created a Pyramid scaffold which integrates Alembic, a migration tool, with the standard SQLAlchemy scaffold. (It also configures the Mako template system, because I prefer Mako.)
I am also using PostgreSQL for my database. PostgreSQL supports nested transactions. This means I can setup the tables at the beginning of the test session, then start a transaction before each test happens and roll it back after the test; in turn, this means my tests operate in the same environment I expect to use in production, but they are also fast.
I based my approach on [sontek's blog post](http://sontek.net/blog/
from flask import Flask | |
import sqlalchemy as sa | |
from sqlalchemy import orm | |
from sqlalchemy.ext.declarative import declarative_base | |
from flask.ext.admin import Admin | |
from flask.ext.admin.contrib import sqla | |
app = Flask(__name__) |
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.
Use production SSL certificates locally. This is annoying
<html> | |
<!-- | |
This is an example of how to make browsers | |
offer to remember password and later fill in those passwords | |
for dynamic login forms. | |
To make the browser offer to remember passwords the form should be actually submitted. | |
Since we are handling login with AJAX we don't want the form to submit, so we are still submitting it | |
into a dummmy iframe with dummy URL. | |
It's good idea to actually create empty dummy.html file, otherwise you'll flood you error.log with 404s |
Using Bootstrap Options: -c /tmp | |
Bootstrapping Salt... (this may take a while) | |
stdin: is not a tty | |
% | |
T | |
o | |
t |
$ sandmanctl postgresql+psycopg2://proj:proj@localhost/proj_v2 | |
/Users/jacob/.venvs/proj-web-py2/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py:1802: SAWarning: Did not recognize type 'geography' of column 'point' | |
name, format_type, default, notnull, domains, enums, schema) | |
/Users/jacob/.venvs/proj-web-py2/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/base.py:1802: SAWarning: Did not recognize type 'geometry' of column 'location' | |
name, format_type, default, notnull, domains, enums, schema) | |
Traceback (most recent call last): | |
File "/Users/jacob/.venvs/proj-web-py2/bin/sandmanctl", line 9, in <module> | |
load_entry_point('sandman==0.7.6', 'console_scripts', 'sandmanctl')() | |
File "/Users/jacob/.venvs/proj-web-py2/lib/python2.7/site-packages/sandman/sandmanctl.py", line 63, in main | |
activate(name='sandmanctl') |
brew remove pyqt | |
brew install pyqt #verify everything works fine | |
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH | |
brew tap homebrew/science | |
brew install qgis --with-grass --with-postgis |
[...migrations running...] | |
Running migrations for social_auth: | |
- Migrating forwards to 0002_auto__add_unique_nonce_timestamp_salt_server_url__add_unique_associati. | |
> social_auth:0001_initial | |
FATAL ERROR - The following SQL query failed: CREATE TABLE "social_auth_usersocialauth" ("id" serial NOT NULL PRIMARY KEY, "user_id" integer NOT NULL, "provider" varchar(32) NOT NULL, "uid" varchar(255) NOT NULL, "extra_data" text NOT NULL); | |
The error was: relation "social_auth_usersocialauth" already exists | |
Error in migration: social_auth:0001_initial | |
Traceback (most recent call last): | |
File "/Users/jacob/.virtualenvs/sentry_venv/bin/sentry", line 9, in <module> |