В настоящее время я озадачен тем, почему я получаю ошибку рекурсии из заголовка с кодом ниже.Эта ошибка появляется только в том случае, если один из циклов for был вызван (под if ops и if compatibility) перед вызовом results = results.all ().
@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)
Как ни странно, код по какой-то причинеработает с одним именем, но без других.Если вам нужна какая-либо другая информация, я с удовольствием предоставлю ее, спасибо!