我有一个Python API,其中有三个端点托管在Azure上。其中一个端点上周开始返回服务器错误。我检查了站台,所以那里一切正常。
我检查了日志,发现对于这个端点,回溯在末尾返回这一行
File ".\app\models.py", line 280, in json
return {'entity': otherentity.name, 'details': self.details, 'entity_id': otherentity.id,
AttributeError: 'NoneType' object has no attribute 'name'
这是stdout和std错误:
StdOut:
StdErr: D:\home\site\wwwroot\env\Lib\site-
packages\flask_cache\jinja2ext.py:33: ExtDeprecationWarning: Importing
flask.ext.cache is deprecated, use flask_cache instead.
from flask.ext.cache import make_template_fragment_key
ErrorCode Access is denied.
(0x5)
第280行引用的代码块是类的一部分。以下是块:
def json(self, entityid):
otherentity = self.entity_1 if entityid == self.entity_id2 else self.entity_2
return {'entity': otherentity.name, 'details': self.details, 'entity_id': otherentity.id,
'id': self.id}
这个应用程序有点像是扔给我的,所以我对调试很陌生,从我所看到的情况来看,问题在于调用。因为它不存在而命名?此外,不确定被弃用的flask\u缓存是否与此问题有关。
我发现flask\u缓存不再维护,我应该改用flask缓存。
有关如何继续修复此服务器错误的任何想法?我不知道为什么使用相同模型的其他两个端点可以工作,但这一个不行。