# Path: damvitool/db.py
# def generate_orm_classes(db_conn_str):
# 
# Path: damvitool/users.py
# class Login:
#     pass
# 
# class Logout:
#     pass
# 
# Path: damvitool/utils.py
# def to_json_type(value):
#     if isinstance(value, (Decimal, datetime, date)):
#         return str(value)
#     return value


from morepath import Response
from sqlalchemy import func, or_, and_, not_, sql
from sqlalchemy.orm import class_mapper, aliased
from damvitool.db import Base, orm_classes, Session
from json import loads
from damvitool.users import Login, Logout
from damvitool.utils import to_json_type
        Get object, with REST API schema

        :return: schema object
        """
        schema = {
            # 'login': request.link(Login()),
            'logout': request.link(Logout()),
            'mode': request.link(Database(), name='mode'),
            'uni-grid-request': request.link(UniGridRequest()),
            'entities': {}
        }
        for c in orm_classes:
            t = Table(c)
            r = Record(c, 0)
            schema['entities'][c] = {
                'get': request.link(t),
                'add': request.link(t, name='add'),
                'record': request.link(r).replace('[0]', '[{' + '},{'.join(
                    [pk.name for pk in class_mapper(orm_classes[c]).primary_key]) + '}]')
            }
        return schema

    def get_mode(self):
        """
        Generate MODE for database

        :return: MODE object
        """
        mode = dict()
        for name in Base.metadata.tables:

# Path: damvitool/db.py
# def generate_orm_classes(db_conn_str):
# 
# Path: damvitool/users.py
# class Login:
#     pass
# 
# class Logout:
#     pass
# 
# Path: damvitool/utils.py
# def to_json_type(value):
#     if isinstance(value, (Decimal, datetime, date)):
#         return str(value)
#     return value


# Path: damvitool/model.py
from morepath import Response
from sqlalchemy import func, or_, and_, not_, sql
from sqlalchemy.orm import class_mapper, aliased
from damvitool.db import Base, orm_classes, Session
from json import loads
from damvitool.users import Login, Logout
from damvitool.utils import to_json_type

        Get object, with REST API schema

        :return: schema object
        """
        schema = {
            # 'login': request.link(Login()),
            'logout': request.link(Logout()),
            'mode': request.link(Database(), name='mode'),
            'uni-grid-request': request.link(UniGridRequest()),
            'entities': {}
        }
        for c in orm_classes:
            t = Table(c)
            r = Record(c, 0)
            schema['entities'][c] = {
                'get': request.link(t),
                'add': request.link(t, name='add'),
                'record': request.link(r).replace('[0]', '[{' + '},{'.join(
                    [pk.name for pk in class_mapper(orm_classes[c]).primary_key]) + '}]')
            }
        return schema

    def get_mode(self):
        """
        Generate MODE for database

        :return: MODE object
        """
        mode = dict()
        for name in Base.metadata.tables:

            self.__process_table(mode, Base.metadata.tables[name])