As a new python developer the magic 'self' identifier doesn't make a whole lot of sense. It seems like self is just magically added to the function call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Have you ever found your self in a place where you deleted all the tables in your | |
# database, but django migrations expects them to be there and throws exceptions | |
# like this: | |
# | |
# _mysql_exceptions.Warning: Table 'mysql.column_stats' doesn't exist | |
# | |
# And your all like "duh, I'm trying to create it!", but django migrations just | |
# doesn't want to cooperate! | |
# | |
# Well I've had issues like this too!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def force_slash(fn): | |
@wraps(fn) | |
def wrapped(*args, **kwargs): | |
if request.environ['PATH_INFO'].endswith('/'): | |
return fn(*args, **kwargs) | |
else: | |
redirect(request.environ['SCRIPT_NAME'] + request.environ['PATH_INFO'] + '/') | |
return wrapped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def CacheFactory(name): | |
cache = manager.get_cache(name) | |
class CacheFactoryInstance(object): | |
class Cache(object): | |
def __init__(self, key): | |
self.key = key | |
def __call__(self, f): | |
def wrapped(*args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import route, abort, Bottle | |
class BasicRoute(object): | |
path = '' | |
def __init__(self, apppath, app): | |
self.app = app | |
self.methods = { | |
'GET': self.get, | |
'POST': self.post, |