# Path: doorman/compat.py
# PY2 = int(sys.version[0]) == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
#     class metaclass(meta):
# 
# Path: doorman/extensions.py
# class LogTee(object):
# class RuleManager(object):
#     class ContextTask(TaskBase):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def handle_status(self, data, **kwargs):
#     def handle_result(self, data, **kwargs):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def load_alerters(self):
#     def should_reload_rules(self):
#     def load_rules(self):
#     def handle_log_entry(self, entry, node):
# def make_celery(app, celery):
#         def __call__(self, *args, **kwargs):


from sqlalchemy.dialects.postgresql import ARRAY, JSONB, INET  # noqa
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import relationship
from doorman.compat import basestring
from doorman.extensions import db
        db.session.add(self)
        if commit:
            db.session.commit()
        return self

    def delete(self, commit=True):
        """Remove the record from the database."""
        db.session.delete(self)
        return commit and db.session.commit()


class Model(CRUDMixin, db.Model):
    """Base model class that includes CRUD convenience methods."""

    __abstract__ = True


# From Mike Bayer's "Building the app" talk
# https://speakerdeck.com/zzzeek/building-the-app
class SurrogatePK(object):
    """A mixin that adds a surrogate integer 'primary key' column named ``id`` to any declarative-mapped class."""

    __table_args__ = {'extend_existing': True}

    id = db.Column(db.Integer, primary_key=True)

    @classmethod
    def get_by_id(cls, record_id):
        """Get record by ID."""
        if any(

# Path: doorman/compat.py
# PY2 = int(sys.version[0]) == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
#     class metaclass(meta):
# 
# Path: doorman/extensions.py
# class LogTee(object):
# class RuleManager(object):
#     class ContextTask(TaskBase):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def handle_status(self, data, **kwargs):
#     def handle_result(self, data, **kwargs):
#     def __init__(self, app=None):
#     def init_app(self, app):
#     def load_alerters(self):
#     def should_reload_rules(self):
#     def load_rules(self):
#     def handle_log_entry(self, entry, node):
# def make_celery(app, celery):
#         def __call__(self, *args, **kwargs):


# Path: doorman/database.py
from sqlalchemy.dialects.postgresql import ARRAY, JSONB, INET  # noqa
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import relationship
from doorman.compat import basestring
from doorman.extensions import db

        db.session.add(self)
        if commit:
            db.session.commit()
        return self

    def delete(self, commit=True):
        """Remove the record from the database."""
        db.session.delete(self)
        return commit and db.session.commit()


class Model(CRUDMixin, db.Model):
    """Base model class that includes CRUD convenience methods."""

    __abstract__ = True


# From Mike Bayer's "Building the app" talk
# https://speakerdeck.com/zzzeek/building-the-app
class SurrogatePK(object):
    """A mixin that adds a surrogate integer 'primary key' column named ``id`` to any declarative-mapped class."""

    __table_args__ = {'extend_existing': True}

    id = db.Column(db.Integer, primary_key=True)

    @classmethod
    def get_by_id(cls, record_id):
        """Get record by ID."""
        if any(

                (isinstance(record_id, basestring) and record_id.isdigit(),