# 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
                cls.__process_table(mode, r.column.table)
                child = mode[r.column.table.name] if r.column.table.name in mode else None
            if child:
                child['relations'].append({
                    'own_attr': r.column.name,
                    'rel_entity': table.name,
                    'rel_attr': r.parent.name,
                    'type': 'one2one'
                })


class Table(object):
    def __init__(self, name):
        self.name = name

    def select(self):
        if self.name not in orm_classes:
            raise Exception('Table {name} doesn\'t exist'.format(name=self.name))
        cls = orm_classes[self.name]
        return Session().query(cls)

    def add(self, vals):
        """Add new row to table

        :param vals: initial values
        :param type: dict
        :return new row object
        """
        cls = orm_classes[self.name]
        obj = cls(**vals)

# 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

                cls.__process_table(mode, r.column.table)
                child = mode[r.column.table.name] if r.column.table.name in mode else None
            if child:
                child['relations'].append({
                    'own_attr': r.column.name,
                    'rel_entity': table.name,
                    'rel_attr': r.parent.name,
                    'type': 'one2one'
                })


class Table(object):
    def __init__(self, name):
        self.name = name

    def select(self):
        if self.name not in orm_classes:
            raise Exception('Table {name} doesn\'t exist'.format(name=self.name))
        cls = orm_classes[self.name]
        return Session().query(cls)

    def add(self, vals):
        """Add new row to table

        :param vals: initial values
        :param type: dict
        :return new row object
        """
        cls = orm_classes[self.name]
        obj = cls(**vals)

        session = Session()