from google.appengine.ext import db
class Log(db.Model):
content = db.StringProperty(multiline=True)
class MyThread(threading.Thread):
def run(self,request):
#logs_query = Log.all().order('-date')
#logs = logs_query.fetch(3)
log=Log()
log.content=request.POST.get('content',None)
log.put()
def Log(request):
thr = MyThread()
thr.start(request)
return HttpResponse('')
错误是:
TypeError at /log
start() takes exactly 1 argument (2 given)
当我不发送请求时
class MyThread(threading.Thread):
def run(self):
log=Log()
log.content=request.POST.get('content',None)
log.put()
def Log(request):
thr = MyThread()
thr.start()
return HttpResponse('')
错误是:
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\Python25\lib\threading.py", line 486, in __bootstrap_inner
self.run()
File "D:\zjm_code\helloworld\views.py", line 33, in run
log.content=request.POST.get('content',None)
NameError: global name 'request' is not defined
你不能在应用程序引擎上使用线程。你知道吗
我不确定这将满足您的需要,甚至可能在谷歌appengine,但
如果将
thr.start(request)
更改为thr.run(request)
,则错误应该消失相关问题 更多 >
编程相关推荐