Please publicly post the following Gist, and name it keybase.md
I hereby claim:
- I am alexanderjulo on github.
- I am alexanderjulo (https://keybase.io/alexanderjulo) on keybase.
- I have a public key ASApykm6Lzuffp-X-V2GUOg_Nmq-mhb5zkQI0fpCxE-WGAo
Please publicly post the following Gist, and name it keybase.md
I hereby claim:
from flask import Flask | |
from celery import Celery | |
def create_app(): | |
app = Flask(__name__) | |
TaskBase = celery.Task | |
class Task(TaskBase): |
import json | |
from wtforms.widgets import Select, HTMLString | |
class ChosenSelect(Select): | |
def __init__(self, multiple=False, renderer=None, options={}): | |
""" | |
Initiate the widget. This offers you two general options. | |
First off it allows you to configure the ChosenSelect to |
from werkzeug.datastructures import OrderedMultiDict | |
from wtforms import widgets, ValidationError | |
from wtforms.compat import text_type | |
from wtforms.ext.sqlalchemy.fields import QuerySelectMultipleField | |
class GroupedSelectMultipleWidget(widgets.Select): | |
""" | |
Renders a select field with groups. Expects a list of tuples when | |
calling `field.iter_choices()`. |
select.form-control + .chosen-container.chosen-container-single .chosen-single { | |
display: block; | |
width: 100%; | |
height: 34px; | |
padding: 6px 12px; | |
font-size: 14px; | |
line-height: 1.428571429; | |
color: #555; | |
vertical-align: middle; | |
background-color: #fff; |
def find_common(*user_ids): | |
queries = [] | |
for user_id in user_ids: | |
query = db.session.query(participants.c.thread_id) \ | |
.filter(participants.c.user_id==user_id) | |
queries.append(query) | |
thread_ids = [r[0] for r in db.session.query(participants.c.thread_id) \ | |
.intersect(*queries).all()] | |
threads = Thread.query.filter(Thread.id.in_(thread_ids)).all() | |
return threads |
# coding: utf8 | |
languages = [ | |
('aa', 'Afar'), | |
('ab', 'Abkhazian'), | |
('af', 'Afrikaans'), | |
('ak', 'Akan'), | |
('sq', 'Albanian'), | |
('am', 'Amharic'), | |
('ar', 'Arabic'), |
@celery.task(name='questionnaire.suitability') | |
@with_request_context | |
def questionnaire_suitability(uid, suitable, treatment, explanation): |
% python test.py | |
teardown request. | |
teardown app context. | |
% |
class with_request_context(object): | |
def __init__(self, f, app=None, request=None): | |
self.f = f | |
if app: | |
self.app = app | |
else: | |
self.app = www | |
if request: | |
self.request = request |