# Path: scribeui_pyramid/modules/app/sqla.py
# def get_session(request):
# def init_sqla(settings):
#     def __props__(self, convert_date=False):
#     def __todict__(self):
#         def convert_datetime(value):
#     def __iter__(self):
#     def __json__(self, request):
#     def fromdict(self, values):
#     def all(cls, page=None, limit=None):
#     def by_id(cls, id):
# def includeme(config):
# class BaseMixin(object):
# 
# Path: scribeui_pyramid/modules/maps/models.py
# class Map(Base, BaseMixin):
# 
#     __tablename__ = 'maps'
#     id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
#     name = sa.Column(sa.Unicode(30), nullable=False)
#     type = sa.Column(sa.Unicode(30), nullable=False)
#     description = sa.Column(sa.Unicode())
#     projection = sa.Column(sa.Unicode())
#     extent = sa.Column(sa.Unicode(50))
#     git_url = sa.Column(sa.Unicode())
# 
#     workspace_id = sa.Column(sa.Integer, sa.ForeignKey('workspaces.id'),
#                              nullable=False)
# 
#     def __repr__(self):
#         return u"<Map('{0}')>".format(self.name)
# 
# 
#     @classmethod
#     def by_name(cls, name):
#         q = DBSession.query(cls)\
#             .filter(sa.func.lower(cls.name) == name.lower())
# 
#         return q.first()


from cryptacular.bcrypt import BCRYPTPasswordManager
from cryptacular.core import DelegatingPasswordManager
from ..app.sqla import (
    DBSession,
    Base,
    BaseMixin
)
from ..maps.models import Map
import sqlalchemy as sa
    @staticmethod
    def encode_password(raw):
        return Workspace.password_manager().encode(raw)


    @staticmethod
    def check_password(hashed, raw):
        return Workspace.password_manager().check(
            hashed,
            raw,
            setter=Workspace.encode_password
        )


    @classmethod
    def authenticate(cls, name, password):
        workspace = DBSession.query(cls)\
            .filter_by(name=name)\
            .first()

        if workspace:
            if workspace.password and password and Workspace.check_password(workspace.password, password):
                return workspace
            elif not workspace.password and not password:
                return workspace
        return None


    @classmethod
    def by_name(cls, name):

# Path: scribeui_pyramid/modules/app/sqla.py
# def get_session(request):
# def init_sqla(settings):
#     def __props__(self, convert_date=False):
#     def __todict__(self):
#         def convert_datetime(value):
#     def __iter__(self):
#     def __json__(self, request):
#     def fromdict(self, values):
#     def all(cls, page=None, limit=None):
#     def by_id(cls, id):
# def includeme(config):
# class BaseMixin(object):
# 
# Path: scribeui_pyramid/modules/maps/models.py
# class Map(Base, BaseMixin):
# 
#     __tablename__ = 'maps'
#     id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
#     name = sa.Column(sa.Unicode(30), nullable=False)
#     type = sa.Column(sa.Unicode(30), nullable=False)
#     description = sa.Column(sa.Unicode())
#     projection = sa.Column(sa.Unicode())
#     extent = sa.Column(sa.Unicode(50))
#     git_url = sa.Column(sa.Unicode())
# 
#     workspace_id = sa.Column(sa.Integer, sa.ForeignKey('workspaces.id'),
#                              nullable=False)
# 
#     def __repr__(self):
#         return u"<Map('{0}')>".format(self.name)
# 
# 
#     @classmethod
#     def by_name(cls, name):
#         q = DBSession.query(cls)\
#             .filter(sa.func.lower(cls.name) == name.lower())
# 
#         return q.first()


# Path: scribeui_pyramid/modules/workspaces/models.py
from cryptacular.bcrypt import BCRYPTPasswordManager
from cryptacular.core import DelegatingPasswordManager
from ..app.sqla import (
    DBSession,
    Base,
    BaseMixin
)
from ..maps.models import Map
import sqlalchemy as sa

    @staticmethod
    def encode_password(raw):
        return Workspace.password_manager().encode(raw)


    @staticmethod
    def check_password(hashed, raw):
        return Workspace.password_manager().check(
            hashed,
            raw,
            setter=Workspace.encode_password
        )


    @classmethod
    def authenticate(cls, name, password):
        workspace = DBSession.query(cls)\
            .filter_by(name=name)\
            .first()

        if workspace:
            if workspace.password and password and Workspace.check_password(workspace.password, password):
                return workspace
            elif not workspace.password and not password:
                return workspace
        return None


    @classmethod
    def by_name(cls, name):

        q = DBSession.query(cls)\