# Path: wallace/db.py
# def sessions_scope(local_session, commit=False):
# def scoped_session_decorator(func):
#     def wrapper(*args, **kwargs):
# def init_db(drop_all=False):
# 
# Path: wallace/models.py
# DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%f"
# def timenow():
#     def __init__(self, worker_id, assignment_id, hit_id, mode):
#     def __json__(self):
#     def nodes(self, type=None, failed=False):
#     def questions(self, type=None):
#     def infos(self, type=None, failed=False):
#     def fail(self):
#     def __init__(self, participant, question, response, number):
#     def fail(self):
#     def __json__(self):
#     def __repr__(self):
#     def __json__(self):
#     def nodes(self, type=None, failed=False, participant_id=None):
#     def size(self, type=None, failed=False):
#     def infos(self, type=None, failed=False):
#     def transmissions(self, status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def latest_transmission_recipient(self):
#     def vectors(self, failed=False):
#     def add_node(self, node):
#     def fail(self):
#     def calculate_full(self):
#     def print_verbose(self):
#     def __init__(self, network, participant=None):
#     def __repr__(self):
#     def __json__(self):
#     def vectors(self, direction="all", failed=False):
#     def neighbors(self, type=None, direction="to", failed=None):
#     def is_connected(self, whom, direction="to", failed=None):
#     def infos(self, type=None, failed=False):
#     def received_infos(self, type=None, failed=None):
#     def transmissions(self, direction="outgoing", status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def fail(self):
#     def connect(self, whom, direction="to"):
#     def flatten(self, l):
#     def transmit(self, what=None, to_whom=None):
#     def _what(self):
#     def _to_whom(self):
#     def receive(self, what=None):
#     def update(self, infos):
#     def replicate(self, info_in):
#     def mutate(self, info_in):
#     def __init__(self, origin, destination):
#     def __repr__(self):
#     def __json__(self):
#     def transmissions(self, status="all"):
#     def fail(self):
#     def __init__(self, origin, contents=None):
#     def _write_once(self, key, value):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def transmissions(self, status="all"):
#     def transformations(self, relationship="all"):
#     def _mutated_contents(self):
#     def __init__(self, vector, info):
#     def mark_received(self):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def __repr__(self):
#     def __init__(self, info_in, info_out):
#     def __json__(self):
#     def fail(self):
# class SharedMixin(object):
# class Participant(Base, SharedMixin):
# class Question(Base, SharedMixin):
# class Network(Base, SharedMixin):
# class Node(Base, SharedMixin):
# class Vector(Base, SharedMixin):
# class Info(Base, SharedMixin):
# class Transmission(Base, SharedMixin):
# class Transformation(Base, SharedMixin):
# class Notification(Base, SharedMixin):


from flask import (
    Blueprint,
    request,
    Response,
    send_from_directory,
    render_template
)
from psiturk.psiturk_config import PsiturkConfig
from psiturk.user_utils import PsiTurkAuthorization
from psiturk.db import init_db
from psiturk.db import db_session as session_psiturk
from wallace import db, models
from operator import attrgetter
from json import dumps
from datetime import datetime
from rq import Queue, get_current_job
from worker import conn
from sqlalchemy.orm.exc import NoResultFound
    from psiturk.models import Participant as PsiturkParticipant
import imp
import inspect
import logging
import os
import requests
import traceback
            .format(request.url, request.method, parameter_type, parameter)
        return error_response(error_type=msg)


def assign_properties(thing):
    """Assign properties to an object.

    When creating something via a post request (e.g. a node), you can pass the
    properties of the object in the request. This function gets those values
    from the request and fills in the relevant columns of the table.
    """
    for p in range(5):
        property_name = "property" + str(p + 1)
        property = request_parameter(parameter=property_name, optional=True)
        if property:
            setattr(thing, property_name, property)

    session.commit()


@custom_code.route("/participant/<worker_id>/<hit_id>/<assignment_id>/<mode>",
                   methods=["POST"])
def create_participant(worker_id, hit_id, assignment_id, mode):
    """Create a participant.

    This route will be hit very early on as any nodes the participant creates
    will be defined in reference to the participant object.
    You must specify the worker_id, hit_id, assignment_id and mode in the url.
    """
    # check this worker hasn't already taken part

# Path: wallace/db.py
# def sessions_scope(local_session, commit=False):
# def scoped_session_decorator(func):
#     def wrapper(*args, **kwargs):
# def init_db(drop_all=False):
# 
# Path: wallace/models.py
# DATETIME_FMT = "%Y-%m-%dT%H:%M:%S.%f"
# def timenow():
#     def __init__(self, worker_id, assignment_id, hit_id, mode):
#     def __json__(self):
#     def nodes(self, type=None, failed=False):
#     def questions(self, type=None):
#     def infos(self, type=None, failed=False):
#     def fail(self):
#     def __init__(self, participant, question, response, number):
#     def fail(self):
#     def __json__(self):
#     def __repr__(self):
#     def __json__(self):
#     def nodes(self, type=None, failed=False, participant_id=None):
#     def size(self, type=None, failed=False):
#     def infos(self, type=None, failed=False):
#     def transmissions(self, status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def latest_transmission_recipient(self):
#     def vectors(self, failed=False):
#     def add_node(self, node):
#     def fail(self):
#     def calculate_full(self):
#     def print_verbose(self):
#     def __init__(self, network, participant=None):
#     def __repr__(self):
#     def __json__(self):
#     def vectors(self, direction="all", failed=False):
#     def neighbors(self, type=None, direction="to", failed=None):
#     def is_connected(self, whom, direction="to", failed=None):
#     def infos(self, type=None, failed=False):
#     def received_infos(self, type=None, failed=None):
#     def transmissions(self, direction="outgoing", status="all", failed=False):
#     def transformations(self, type=None, failed=False):
#     def fail(self):
#     def connect(self, whom, direction="to"):
#     def flatten(self, l):
#     def transmit(self, what=None, to_whom=None):
#     def _what(self):
#     def _to_whom(self):
#     def receive(self, what=None):
#     def update(self, infos):
#     def replicate(self, info_in):
#     def mutate(self, info_in):
#     def __init__(self, origin, destination):
#     def __repr__(self):
#     def __json__(self):
#     def transmissions(self, status="all"):
#     def fail(self):
#     def __init__(self, origin, contents=None):
#     def _write_once(self, key, value):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def transmissions(self, status="all"):
#     def transformations(self, relationship="all"):
#     def _mutated_contents(self):
#     def __init__(self, vector, info):
#     def mark_received(self):
#     def __repr__(self):
#     def __json__(self):
#     def fail(self):
#     def __repr__(self):
#     def __init__(self, info_in, info_out):
#     def __json__(self):
#     def fail(self):
# class SharedMixin(object):
# class Participant(Base, SharedMixin):
# class Question(Base, SharedMixin):
# class Network(Base, SharedMixin):
# class Node(Base, SharedMixin):
# class Vector(Base, SharedMixin):
# class Info(Base, SharedMixin):
# class Transmission(Base, SharedMixin):
# class Transformation(Base, SharedMixin):
# class Notification(Base, SharedMixin):


# Path: wallace/custom.py
from flask import (
    Blueprint,
    request,
    Response,
    send_from_directory,
    render_template
)
from psiturk.psiturk_config import PsiturkConfig
from psiturk.user_utils import PsiTurkAuthorization
from psiturk.db import init_db
from psiturk.db import db_session as session_psiturk
from wallace import db, models
from operator import attrgetter
from json import dumps
from datetime import datetime
from rq import Queue, get_current_job
from worker import conn
from sqlalchemy.orm.exc import NoResultFound
    from psiturk.models import Participant as PsiturkParticipant
import imp
import inspect
import logging
import os
import requests
import traceback

            .format(request.url, request.method, parameter_type, parameter)
        return error_response(error_type=msg)


def assign_properties(thing):
    """Assign properties to an object.

    When creating something via a post request (e.g. a node), you can pass the
    properties of the object in the request. This function gets those values
    from the request and fills in the relevant columns of the table.
    """
    for p in range(5):
        property_name = "property" + str(p + 1)
        property = request_parameter(parameter=property_name, optional=True)
        if property:
            setattr(thing, property_name, property)

    session.commit()


@custom_code.route("/participant/<worker_id>/<hit_id>/<assignment_id>/<mode>",
                   methods=["POST"])
def create_participant(worker_id, hit_id, assignment_id, mode):
    """Create a participant.

    This route will be hit very early on as any nodes the participant creates
    will be defined in reference to the participant object.
    You must specify the worker_id, hit_id, assignment_id and mode in the url.
    """
    # check this worker hasn't already taken part

    parts = models.Participant.query.filter_by(worker_id=worker_id).all()