Skip to content

Instantly share code, notes, and snippets.

💭
Headphones.

Peter peter-conalgo

💭
Headphones.
View GitHub Profile
View gist:68317466c577396b4450
### Keybase proof
I hereby claim:
* I am peter-conalgo on github.
* I am dochex (https://keybase.io/dochex) on keybase.
* I have a public key whose fingerprint is 4589 779A DFC1 4F33 2753 4EA8 A3A3 1BAD 5A2A 5B10
To claim this, I am signing this object:
@peter-conalgo
peter-conalgo / sqlalchemy_getindex
Created Mar 16, 2014
Flask-Sqlalchemy monkey patch to simplify debug with: DBObjectClassName[pk_value]
View sqlalchemy_getindex
# Hack to allow me to type just ClassName[34] and fetch DB object with pk=34
#
from flask.ext.sqlalchemy import _BoundDeclarativeMeta
def _get_by_pk(cls, idx):
return cls.get(idx)
_BoundDeclarativeMeta.__getitem__ = _get_by_pk
You can’t perform that action at this time.