コード例 #1
0
    def __new__(cls, name, bases, attrs):
        """

        :param name:
        :param bases:from easyapi import MysqlDB

        :param attrs:
        :return:
        """
        if "BaseDao" in name:
            return type.__new__(cls, name, bases, attrs)
        if attrs.get('__db__') is None:
            raise NotImplementedError("Should have __db__ value.")

        attrs['__tablename__'] = attrs.get('__tablename__') or str2hump(
            name[:-3]) + 's'

        table = attrs['__db__'][attrs['__tablename__']]  # type: Table
        attrs['__table__'] = table

        for c in table.c:
            attrs[c.name] = c.name
            attrs['_lte_' + c.name] = '_lte_' + c.name
            attrs['_gt_' + c.name] = '_gt_' + c.name

            attrs['_lte_' + c.name] = '_lte_' + c.name
            attrs['_lt_' + c.name] = '_lt_' + c.name

            attrs['_like_' + c.name] = '_like_' + c.name
            attrs['_in_' + c.name] = '_in_' + c.name

        return type.__new__(cls, name, bases, attrs)
コード例 #2
0
    def __new__(cls, name, bases, attrs):
        """

        :param name:
        :param bases:
        :param attrs:
        :return:
        """
        if "BaseDao" in name:
            return type.__new__(cls, name, bases, attrs)
        if attrs.get('__db__') is None:
            raise NotImplementedError("Should have __db__ value.")

        attrs['__tablename__'] = attrs.get('__tablename__') or str2hump(name[:-3]) + 's'
        return type.__new__(cls, name, bases, attrs)
コード例 #3
0
    def __new__(cls, name, bases, attrs):
        """

        :param name:
        :param bases:
        :param attrs:
        :return:
        """
        if "BaseHandler" in name:
            return type.__new__(cls, name, bases, attrs)

        attrs['__resource__'] = attrs.get('__resource__') or str2hump(
            name[:-7])
        attrs['__url_condition__'] = attrs.get(
            '__url_condition__') or DefaultUrlCondition
        if not attrs.get('__controller__'):
            raise NotImplementedError("Handler require a  controller.")

        return type.__new__(cls, name, bases, attrs)