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
import sys | |
from werkzeug.datastructures import ImmutableDict, MultiDict | |
from flask import request | |
from flaskext.script import Manager | |
from postfixmgmt import app, db, __version__ | |
from postfixmgmt.forms import DomainAddForm | |
manager = Manager(app) | |
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
# This does nothing | |
collection.find_and_modify({'_id': 'deadbeef'}, {$set: {}}) | |
# This clears a document | |
collection.find_and_modify({'_id': 'deadbeef'}, {}) |
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
class Model(object): | |
... | |
def save(self, ops=None): | |
ops = dict(ops or ()) | |
for column in self.modified_columns: | |
ops.setdefault('$set', {})[column] = self.data[column] | |
rv = self.collection.find_and_modify({'_id': self.id}, ops) | |
self.data.update(rv) |
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 flask import _request_ctx_stack | |
app.jinja_env.globals['get_subdomain'] = lambda: _request_ctx_stack.top.url_adapter.subdomain |
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
import threading | |
import greenlet | |
while 1: | |
t = threading.Thread(target=greenlet.getcurrent) | |
t.start() | |
t.join() |
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 proxy_fix(application): | |
def new_application(environ, start_response): | |
environ['wsgi.url_scheme'] = 'https' | |
return application(environ, start_response) | |
return new_application | |
app.wsgi_app = proxy_fix(app.wsgi_app) |
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
upstream fireteam-frontend-upstream { | |
server 1; | |
server 9; | |
server 2; | |
server .; | |
server 1; | |
server 6; | |
server 8; | |
server .; | |
server 3; |
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
import zmq | |
import time | |
ctx = zmq.Context() | |
socket = ctx.socket(zmq.REQ) | |
socket.connect('tcp://127.0.0.1:5000') | |
print 'Sending auth information' | |
socket.send('auth') | |
print 'Response:', socket.recv() |
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
$ python routetest.py | |
/ | |
>>> group_list(www2) | |
/aha | |
>>> jot_list(www2, aha, None) | |
/aha:blah | |
>>> jot_list(www2, aha, blah) |
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
Debugging middleware caught exception in streamed response at a point where response headers were already sent. | |
Traceback (most recent call last): | |
File "/home/max/.virtualenvs/flask/lib/python2.7/site-packages/werkzeug/wsgi.py", line 513, in next | |
return self._next() | |
File "/home/max/.virtualenvs/flask/lib/python2.7/site-packages/werkzeug/wrappers.py", line 829, in iter_encoded | |
for item in self.response: | |
File "/home/max/.virtualenvs/flask/lib/python2.7/site-packages/jinja2/environment.py", line 918, in generate | |
yield self.environment.handle_exception(exc_info, True) | |
File "/home/max/Projekte/flask-testing-stuff/templates/index.html", line 1, in top-level template code | |
{% extends "layout.html" %} |
OlderNewer