Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQLAlchemy RecursionError:调用Python对象时超出了最大递归深度_Python_Recursion_Sqlalchemy_Flask Sqlalchemy - Fatal编程技术网

SQLAlchemy RecursionError:调用Python对象时超出了最大递归深度

SQLAlchemy RecursionError:调用Python对象时超出了最大递归深度,python,recursion,sqlalchemy,flask-sqlalchemy,Python,Recursion,Sqlalchemy,Flask Sqlalchemy,我现在很困惑,为什么我要用下面的代码从标题中设计递归错误。只有在调用results=results.all()之前命中了for循环中的任何一个(在if ops和if compliance下)时,才会出现此错误 奇怪的是,出于某种原因,代码只能使用一个名称,而不能使用其他名称。如果您需要任何其他信息,我很乐意提供,谢谢 您似乎在循环结果并在循环中修改结果。我不确定这是否会导致您得到的错误,但这不是很有效。更好的方法可能是循环查看results并收集要在列表中过滤掉的id,然后执行类似results

我现在很困惑,为什么我要用下面的代码从标题中设计递归错误。只有在调用results=results.all()之前命中了for循环中的任何一个(在if ops和if compliance下)时,才会出现此错误


奇怪的是,出于某种原因,代码只能使用一个名称,而不能使用其他名称。如果您需要任何其他信息,我很乐意提供,谢谢

您似乎在循环
结果
并在循环中修改
结果
。我不确定这是否会导致您得到的错误,但这不是很有效。更好的方法可能是循环查看
results
并收集要在列表中过滤掉的id,然后执行类似
results=results.filter(not_u(Envelope.Envelope\u id.in_u(list_of_不需要的\u id))
(您可能必须从sqlalchemy导入
not_u
)的操作。这实际上解决了这个问题,非常感谢!
@main.route('/search_results', methods=['GET', 'POST'])
@login_required
def search_results():
    """ Here we make the search request and then display the results.  We bring in
    the params via the url, then use whooshalchemy to search fields we marked
    with __searchable__ in the model.  If advanced search is selected, we then filter
    the results before we display.  Note that there are two separate searches for the
    separate data types. """
    subject = request.args.get('subject')
    search_type = request.args.get('search_type')
    acct_no = request.args.get('acct_no')
    id_ = request.args.get('id_')
    rep = request.args.get('rep')
    ops = request.args.get('ops')
    compliance = request.args.get('compliance')
    results = []

    ...

    else:
        results = db.session.query(Envelope)
        if subject is not None and subject is not '':
            results = results.filter(Envelope.subject.like('%'+subject+'%'))
        if acct_no is not None and acct_no is not '':
            results = results.filter_by(acct_no=acct_no)
        if id_ is not None and id_ is not None:
            id_ = int(id_)
            results = results.filter_by(envelope_id=id_)
        if rep is not None and rep is not '' :
            results = results.filter_by(initiator=rep)
        if ops is not None and ops is not '':
            ops_name = external_db.get_fullname_from_username(ops)
            for result in results:
                if db.session.query(Envelope_recipient).filter_by(envelope_id=result.envelope_id,role='Operations',name=ops_name).first() == None:
                    results = results.filter(Envelope.envelope_id != result.envelope_id)
        if compliance is not None and compliance is not '':
            compliance_name = external_db.get_fullname_from_username(ops)
            for result in results:
                if db.session.query(Envelope_recipient).filter_by(envelope_id=result.envelope_id,role='Compliance',name=compliance_name).first() == None:
                    results = results.filter(Envelope.envelope_id != result.envelope_id)

    #results.all() is a list of all esignature.models.Envelope or .Process_item objects
    results = results.all()

    return render_template('search_results.html', subject=subject,
                        search_type=search_type, acct_no=acct_no,
                        id_=id_, rep=rep, ops=ops,
                        compliance=compliance, results=results)