# Path: flask_editablesite/extensions.py

# 
# Path: flask_editablesite/compat.py
# PY2 = int(sys.version[0]) == 2


from datetime import datetime
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import relationship, validates
from slugify import slugify
from .extensions import db
from .compat import basestring
        from flask_babel import format_datetime
        from flask_babel import format_datetime
        from flask_babel import format_datetime
        for attr, value in kwargs.iteritems():
            setattr(self, attr, value)
        return commit and self.save() or self

    def save(self, commit=True):
        """Save the record."""
        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}


# Path: flask_editablesite/extensions.py

# 
# Path: flask_editablesite/compat.py
# PY2 = int(sys.version[0]) == 2


# Path: flask_editablesite/database.py
from datetime import datetime
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import relationship, validates
from slugify import slugify
from .extensions import db
from .compat import basestring
        from flask_babel import format_datetime
        from flask_babel import format_datetime
        from flask_babel import format_datetime

        for attr, value in kwargs.iteritems():
            setattr(self, attr, value)
        return commit and self.save() or self

    def save(self, commit=True):
        """Save the record."""
        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)