# Path: pgcontents/constants.py
# UNLIMITED = 0
# 
# Path: pgcontents/crypto.py
# class NoEncryption(object):
#     """
#     No-op encryption backend.
# 
#     encrypt() and decrypt() simply return their inputs.
# 
#     Methods
#     -------
#     encrypt : callable[bytes -> bytes]
#     decrypt : callable[bytes -> bytes]
#     """
#     def encrypt(self, b):
#         return b
# 
#     def decrypt(self, b):
#         return b
# 
# Path: pgcontents/query.py
# def ensure_db_user(db, user_id):
#     """
#     Add a new user if they don't already exist.
#     """
#     with ignore_unique_violation():
#         db.execute(
#             users.insert().values(id=user_id),
#         )
# 
# Path: pgcontents/utils/ipycompat.py



from getpass import getuser
from sqlalchemy import (
    create_engine,
)
from sqlalchemy.engine.base import Engine
from tornado.web import HTTPError
from .constants import UNLIMITED
from .crypto import NoEncryption
from .query import ensure_db_user
from .utils.ipycompat import Any, Bool, Instance, Integer, HasTraits, Unicode
"""
Mixin for classes interacting with the pgcontents database.
"""



class PostgresManagerMixin(HasTraits):
    """
    Shared behavior for Postgres-backed ContentsManagers.
    """
    db_url = Unicode(
        default_value="postgresql://{user}@/pgcontents".format(
            user=getuser(),
        ),
        config=True,
        help="Connection string for the database.",
    )


# Path: pgcontents/constants.py
# UNLIMITED = 0
# 
# Path: pgcontents/crypto.py
# class NoEncryption(object):
#     """
#     No-op encryption backend.
# 
#     encrypt() and decrypt() simply return their inputs.
# 
#     Methods
#     -------
#     encrypt : callable[bytes -> bytes]
#     decrypt : callable[bytes -> bytes]
#     """
#     def encrypt(self, b):
#         return b
# 
#     def decrypt(self, b):
#         return b
# 
# Path: pgcontents/query.py
# def ensure_db_user(db, user_id):
#     """
#     Add a new user if they don't already exist.
#     """
#     with ignore_unique_violation():
#         db.execute(
#             users.insert().values(id=user_id),
#         )
# 
# Path: pgcontents/utils/ipycompat.py



# Path: pgcontents/managerbase.py
from getpass import getuser
from sqlalchemy import (
    create_engine,
)
from sqlalchemy.engine.base import Engine
from tornado.web import HTTPError
from .constants import UNLIMITED
from .crypto import NoEncryption
from .query import ensure_db_user
from .utils.ipycompat import Any, Bool, Instance, Integer, HasTraits, Unicode

"""
Mixin for classes interacting with the pgcontents database.
"""



class PostgresManagerMixin(HasTraits):
    """
    Shared behavior for Postgres-backed ContentsManagers.
    """
    db_url = Unicode(
        default_value="postgresql://{user}@/pgcontents".format(
            user=getuser(),
        ),
        config=True,
        help="Connection string for the database.",
    )


    user_id = Unicode(