我使用龙卷风获取域列表,并迭代这些域并为每个域运行一个进程。我不断收到错误,我可能做了一些简单的错误,但我无法弄明白。
这里是追溯:
File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 699, in render
html = self.render_string(template_name, **kwargs)
File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 804, in render_string
namespace = self.get_template_namespace()
File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 828, in get_template_namespace
namespace.update(self.ui)
TypeError: 'NoneType' object is not iterable
以下是代码:
class MainHandler(tornado.web.RequestHandler):
def get(self):
# product = self.get_argument('product-type', '')
apikey = self.get_argument('apikey', '')
domain = self.get_argument('domain', '')
start = self.get_argument('start', '')
end = self.get_argument('end', '')
urls = domain.split(",")
for u in urls:
filePath = u + "_" + start + "_" + end + ".csv"
if apikey:
results = max_concurrents(apikey, u, start, end, save_to=True)
if filePath:
print filePath + 'valid'
self.render('index.html', data=filePath, domain=u, start=start, end=end)
else:
print filePath + 'invalid'
self.render('index.html', data=filePath)
def post(self):
# product = self.get_argument('product-type', '')
apikey = self.get_argument('apikey','')
domain = self.get_argument('domain','')
start = self.get_argument('start','')
end = self.get_argument('end','')
urls = domain.split(",")
for u in urls:
filePath = u + "_" + start + "_" + end + ".csv"
print filePath
print r
答案 0 :(得分:1)
这意味着for is迭代的是None。我怀疑url
因为for迭代而为None。
添加一些调试以确定url
是否为无或具有某些值。
答案 1 :(得分:0)
您不能多次拨打RequestHandler.render()
;这样就完成了请求(并使处理程序处于无效状态,因此通常只需在渲染后返回)。如果您只想连接所有模板渲染,那么您可以调用self.write(self.render_string('index.html', ...))
。