我正在尝试设置一个包含对象列表、对象属性名称和对象属性值的调试页面。我正在尝试获取特定对象类型的特定属性的值。当我编码时,对象类型或属性都不知道。
以下是我为之准备的相关部分:
在我的 test.py
if self.request.get('objID'):
qGet = self.request.get
thisObj = db.get(db.Key(qGet('objID')))
template_values = { 'thisObj' : thisObj }
template = JINJA_ENVIRONMENT.get_template('objProp.html')
self.response.write(template.render(template_values))
在我的 objProp.html 模板中
{% if thisObj %}
<ul>List of properties
{% for p in thisObj.properties() %}
<li>{{ p }} : {{ thisObj.p }}</li>
{% endfor %}
</ul>
{% endif %}
然而,由于 thisObj 中没有属性 p 它总是打印出一个空值,我真的想要打印出在循环中的特定点处 p 所指的任何属性的值
任何帮助将不胜感激!