コード例 #1
0
ファイル: user.py プロジェクト: Alifazaeli/podia
    def as_dict(self, ignorefields):
        """
        this method convert sqlalchemy object to dict

        :param: self : object of models
        :type : object
        :param : ignorefields
        :type : list of ignore fields
        :rtype : dict
        """
        result = {}
        for key in self.__mapper__.c.keys():
            if key not in ignorefields:
                if type(getattr(self, key)) == datetime:
                    result[key] = dump_datetime(getattr(self, key))
                else:
                    result[key] = getattr(self, key)
        return result
コード例 #2
0
    def as_dict(self, ignorefields):
        """
        this method convert sqlalchemy object to dict

        :param: self : object of models
        :type : object
        :param : ignorefields
        :type : list of ignore fields
        :rtype : dict
        """
        result = OrderedDict()
        for key in self.__mapper__.c.keys():
            if key not in ignorefields:
                if type(getattr(self, key)) == datetime:
                    result[key] = dump_datetime(getattr(self, key))
                else:
                    result[key] = getattr(self, key)
        return result
コード例 #3
0
ファイル: podcast.py プロジェクト: Alifazaeli/podia
    def as_dict(self, ignorefields):
        """
        this method convert sqlalchemy object to dict

        :param: self : object of models
        :type : object
        :param : ignorefields
        :type : list of ignore fields
        :rtype : dict
        """
        result = OrderedDict()
        for key in self.__mapper__.c.keys():
            if key not in ignorefields:
                if type(getattr(self, key)) == datetime.datetime:
                    result[key] = dump_datetime(getattr(self, key))
                elif type(getattr(self, key)) == datetime.time:
                    result[key] = dump_time(getattr(self, key))
                else:
                    result[key] = getattr(self, key)

        result['channel'] = self.channel.as_dict(['id', 'views'])
        return result