うまく機能していないように見える古いPythonコードがいくつかあります。インターネットの端まで調べて、修正を見つけようとしました。
def getURL(self, context):
# Make this an absolute URL- currently it's required for
# links placed in the RSS and XML feeds, and won't
# hurt elsewhere.
req = context['request']
port = req.host[2]
hostname = req.getRequestHostname()
if req.isSecure():
default = 443
else:
default = 80
if port == default:
hostport = ''
else:
hostport = ':%d' % port
path = posixpath.join('/stats',
*(tuple(self.target.pathSegments) + self.relativePathSegments))
return quote('http%s://%s%s%s' % (
req.isSecure() and 's' or '',
hostname,
hostport,
path), "/:")
今、私はそれcontext['request']
が私に問題を与えているだけだと思いますが、私にはわかりません。このコードブロックはCIA.vcプロジェクト(正確にはlink.py)からのものであるため、何か意味がない場合はそこで確認してください
また、Pythonから取得する最初のエラーは次のとおりです。
File "/home/justasic/cia/cia/LibCIA/Web/Stats/Link.py", line 41, in getURL port = req.host[2]
exceptions.TypeError: unindexable object
context['request']
しかし、簡単な修正だと思うものを見つけた後、定義されていないことについてもっと知りました