views:

34

answers:

2
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 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
A: 

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

S.Mark
Note: Google does not allow threading in their servers according to document.
S.Mark
+1  A: 

You cannot use threads on App Engine.

Nick Johnson