开发者

how to send some data to the Thread module on python and google-map-engine

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('')

error is :

TypeError at /log
start() takes exactly 1 argument (2 given)

and when i don't send the request,

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('')

the error is :

Exception in thre开发者_如何转开发ad 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


You cannot use threads on App Engine.


I am not sure this will meet your needs or even possible in google appengine but

if you change thr.start(request) to thr.run(request) the error should gone

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜