2016-06-28 60 views
0

我試圖測試燒瓶編輯包(https://github.com/nathancahill/Flask-Edits燒瓶編輯:AttributeError的:「的TokenStream」對象有沒有屬性「下一個」

任何人都可以與此錯誤的幫助:AttributeError的:「的TokenStream」對象有沒有屬性 '下一個'

@app.route('/') 
    def hello_world(): 
     return render_template('test.html') 

    if __name__ == '__main__': 
     app.run(debug=True) 

模板:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Haldane</title> 
</head> 
<body> 

<p>Test</p> 

{% editable 'Section name' %} 
    Python is a programming language that lets you work quickly and integrate systems more effectively. 
{% endeditable %} 

</body> 
</html> 

出現的錯誤在這裏:

"""Jinja extensions to mark sections as editable 
""" 
import hashlib 
from collections import OrderedDict 
from jinja2.nodes import Output, Template, TemplateData 
from jinja2.ext import Extension 

class EditableExtension(Extension): 
    tags = set(['editable']) 

    def parse(self, parser): 
     _db = self.environment.edits 

     # Skip begining node 
     parser.stream.next() 

錯誤:

File "/anaconda/lib/python3.5/site-packages/flask_edits/editable.py", line 18, in parse 
parser.stream.next() 
AttributeError: 'TokenStream' object has no attribute 'next' 

主旨包括代碼: https://gist.github.com/archienorman11/98993d66fc30283ba113f8a4f2b39669

回答

1

假設燒瓶編輯希望支持Python 3中,這是在燒瓶編輯中的錯誤。它應該使用內建函數next來推進迭代器:next(parser.stream)。迭代器上的方法從Python 2和3之間的next更改爲__next__。內置函數適用於兩者。

相關問題