GAE 必须以 Movie 实例作为第一个参数调用未绑定方法 put() 是什么意思
第一个
错误:
ERROR 2011-04-22 23:25:15,513 __init__.py:395] unbound method put() must be called with Movie instance as first argument (got nothing instead)
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 515, in __call__
handler.get(*groups)
File "C:\Users\Jimenez\workspace\elmovieplace\src\script/crawl.py", line 86, in get
getImdbData(year, findPatGamma, findPatGamma2)
File "C:\Users\Jimenez\workspace\elmovieplace\src\script/crawl.py", line 66, in getImdbData
movie.put()
TypeError: unbound method put() must be called with Movie instance as first argument (got nothing instead)
crawl.py:
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from urllib2 import urlopen
from Classes import Movie
import re
def getImdbData(year, findPatGamma, findPatGamma2):
templistone = []
templisttwo = []
listIterator = []
listIterator[:] = range(len(findPatGamma))
for gi in listIterator:
deltaUrl = findPatGamma[gi]
deltaPage = urlopen(deltaUrl).read()
print deltaUrl
simpleone = (re.findall(re.compile("""id='hmovie'.*[^\n]src='|"(.*[^\n])'|".*[^\n]"""),deltaPage))[0]
templistone.append(simpleone)
simpletwo = (re.findall(re.compile("<title>Project Free TV - (.*) video</title>"),deltaPage))[0]
templisttwo.append(simpletwo)
movie = Movie
url = 'http://www.imdbapi.com/?plot=full&t=' + findPatGamma2[0] + '&y=' + year
imdbPage = urlopen(url).read()
imdbValues, = re.findall(re.compile('{"Title":"(.*)","Year":"(.*)","Rated":"(.*)","Released":"(.*)","Genre":"(.*)","Director":"(.*)","Writer":"(.*)","Actors":"(.*)","Plot":"(.*)","Poster":"(.*)","Runtime":"(.*)","Rating":"(.*)","Votes":"(.*)","ID":"(.*)","Response":"(.*)"}'),imdbPage)
movie.title = imdbValues[0]#done
if imdbValues[1] == 'N/A':
movie.rated = ''
else:
movie.rated = imdbValues[2]#done
if imdbValues[3] == 'N/A':
movie.releaseDate = 'jan 1 1990'
else:
movie.releaseDate = imdbValues[3]
if imdbValues[4] == 'N/A':
movie.tags = [];
else:
movie.tags = re.findall(re.compile('(\w*[^\s|,])'),imdbValues[4])#done
if imdbValues[5] == 'N/A':
movie.diector = ''
else:
movie.director = imdbValues[5],#done
if imdbValues[6] == 'N/A':
movie.writer = ''
else:
movie.writer = imdbValues[6],#done
if imdbValues[7] == 'N/A':
movie.actors = []
else:
movie.actors = re.findall(re.compile('(\w*[^\s|,])'),imdbValues[7])#done
if imdbValues[8] == 'N/A':
movie.description = ''
else:
movie.description = imdbValues[8]#done
if imdbValues[9] == 'N/A':
movie.pic = ''
else:
movie.pic = imdbValues[9]#done
if imdbValues[10] == 'N/A':
movie.length = 0
else:
movie.length = (60 * int((re.findall(re.compile('(.*) hrs .* mins'),imdbValues[10]))[0])) + int((re.findall(re.compile('.* hrs (.*) mins'),imdbValues[10]))[0])#done
movie.uniqueID = imdbValues[13]#done
movie.hostNames = templisttwo
movie.hostUrls = templistone
movie.put()
return
class MyHandler(webapp.RequestHandler):
def get(self):
year = '2011'
betaUrl = 'http://www.free-tv-video-online.me/movies/' + year + '/'
betaPage = urlopen(betaUrl).read()
patFinderBeta = re.compile('<td width="97%" class="mnlcategorylist"><a href="(.*)">')
findPatBeta = re.findall(patFinderBeta,betaPage)
listIteratorBeta = []
listIteratorBeta[:] = range(len(findPatBeta))
for bi in listIteratorBeta:
gammaUrl = betaUrl + findPatBeta[bi]
gammaPage = urlopen(gammaUrl).read()
patFinderGamma = re.compile('<a href="(.*[^\n])" target="_blank" class="mnllinklist">')
findPatGamma = re.findall(patFinderGamma,gammaPage)
patFinderGamma2 = re.compile('<meta name="keywords"content="(.*)">')
findPatGamma2 = re.findall(patFinderGamma2,gammaPage)
getImdbData(year, findPatGamma, findPatGamma2)
ip = self.request.remote_addr
template_values = {
'username': ip,
}
self.response.out.write(template.render('template\crawl.html', template_values))
def main():
app = webapp.WSGIApplication([(r'.*', MyHandler)],debug=True)
wsgiref.handlers.CGIHandler().run(app)
if __name__ == '__main__':
main()
Classes.py:
from google.appengine.ext import db
class Movie(db.Model):
title = db.StringProperty()
hostNames = db.StringProperty()
hostUrls = db.StringListProperty()
releaseDate = db.DateProperty()
uniqueID = db.StringProperty(default='000000')
playcount = db.IntegerProperty(default='0')
length = db.IntegerProperty()
rated = db.StringProperty()
description = db.StringProperty()
tags = db.StringListProperty()
director = db.StringProperty()
writer = db.StringProperty()
actors = db.StringProperty()
pic = db.StringProperty()
我浏览了一些帖子(换句话说,我现在已经搜索了一天),但我不知道我做错了什么。
“O”,顺便说一句,把我的问题放在一起并没有表明这一点,我是新手。
First
Error:
ERROR 2011-04-22 23:25:15,513 __init__.py:395] unbound method put() must be called with Movie instance as first argument (got nothing instead)
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 515, in __call__
handler.get(*groups)
File "C:\Users\Jimenez\workspace\elmovieplace\src\script/crawl.py", line 86, in get
getImdbData(year, findPatGamma, findPatGamma2)
File "C:\Users\Jimenez\workspace\elmovieplace\src\script/crawl.py", line 66, in getImdbData
movie.put()
TypeError: unbound method put() must be called with Movie instance as first argument (got nothing instead)
crawl.py:
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from urllib2 import urlopen
from Classes import Movie
import re
def getImdbData(year, findPatGamma, findPatGamma2):
templistone = []
templisttwo = []
listIterator = []
listIterator[:] = range(len(findPatGamma))
for gi in listIterator:
deltaUrl = findPatGamma[gi]
deltaPage = urlopen(deltaUrl).read()
print deltaUrl
simpleone = (re.findall(re.compile("""id='hmovie'.*[^\n]src='|"(.*[^\n])'|".*[^\n]"""),deltaPage))[0]
templistone.append(simpleone)
simpletwo = (re.findall(re.compile("<title>Project Free TV - (.*) video</title>"),deltaPage))[0]
templisttwo.append(simpletwo)
movie = Movie
url = 'http://www.imdbapi.com/?plot=full&t=' + findPatGamma2[0] + '&y=' + year
imdbPage = urlopen(url).read()
imdbValues, = re.findall(re.compile('{"Title":"(.*)","Year":"(.*)","Rated":"(.*)","Released":"(.*)","Genre":"(.*)","Director":"(.*)","Writer":"(.*)","Actors":"(.*)","Plot":"(.*)","Poster":"(.*)","Runtime":"(.*)","Rating":"(.*)","Votes":"(.*)","ID":"(.*)","Response":"(.*)"}'),imdbPage)
movie.title = imdbValues[0]#done
if imdbValues[1] == 'N/A':
movie.rated = ''
else:
movie.rated = imdbValues[2]#done
if imdbValues[3] == 'N/A':
movie.releaseDate = 'jan 1 1990'
else:
movie.releaseDate = imdbValues[3]
if imdbValues[4] == 'N/A':
movie.tags = [];
else:
movie.tags = re.findall(re.compile('(\w*[^\s|,])'),imdbValues[4])#done
if imdbValues[5] == 'N/A':
movie.diector = ''
else:
movie.director = imdbValues[5],#done
if imdbValues[6] == 'N/A':
movie.writer = ''
else:
movie.writer = imdbValues[6],#done
if imdbValues[7] == 'N/A':
movie.actors = []
else:
movie.actors = re.findall(re.compile('(\w*[^\s|,])'),imdbValues[7])#done
if imdbValues[8] == 'N/A':
movie.description = ''
else:
movie.description = imdbValues[8]#done
if imdbValues[9] == 'N/A':
movie.pic = ''
else:
movie.pic = imdbValues[9]#done
if imdbValues[10] == 'N/A':
movie.length = 0
else:
movie.length = (60 * int((re.findall(re.compile('(.*) hrs .* mins'),imdbValues[10]))[0])) + int((re.findall(re.compile('.* hrs (.*) mins'),imdbValues[10]))[0])#done
movie.uniqueID = imdbValues[13]#done
movie.hostNames = templisttwo
movie.hostUrls = templistone
movie.put()
return
class MyHandler(webapp.RequestHandler):
def get(self):
year = '2011'
betaUrl = 'http://www.free-tv-video-online.me/movies/' + year + '/'
betaPage = urlopen(betaUrl).read()
patFinderBeta = re.compile('<td width="97%" class="mnlcategorylist"><a href="(.*)">')
findPatBeta = re.findall(patFinderBeta,betaPage)
listIteratorBeta = []
listIteratorBeta[:] = range(len(findPatBeta))
for bi in listIteratorBeta:
gammaUrl = betaUrl + findPatBeta[bi]
gammaPage = urlopen(gammaUrl).read()
patFinderGamma = re.compile('<a href="(.*[^\n])" target="_blank" class="mnllinklist">')
findPatGamma = re.findall(patFinderGamma,gammaPage)
patFinderGamma2 = re.compile('<meta name="keywords"content="(.*)">')
findPatGamma2 = re.findall(patFinderGamma2,gammaPage)
getImdbData(year, findPatGamma, findPatGamma2)
ip = self.request.remote_addr
template_values = {
'username': ip,
}
self.response.out.write(template.render('template\crawl.html', template_values))
def main():
app = webapp.WSGIApplication([(r'.*', MyHandler)],debug=True)
wsgiref.handlers.CGIHandler().run(app)
if __name__ == '__main__':
main()
Classes.py:
from google.appengine.ext import db
class Movie(db.Model):
title = db.StringProperty()
hostNames = db.StringProperty()
hostUrls = db.StringListProperty()
releaseDate = db.DateProperty()
uniqueID = db.StringProperty(default='000000')
playcount = db.IntegerProperty(default='0')
length = db.IntegerProperty()
rated = db.StringProperty()
description = db.StringProperty()
tags = db.StringListProperty()
director = db.StringProperty()
writer = db.StringProperty()
actors = db.StringProperty()
pic = db.StringProperty()
I've looked around some post (in other words I've been searching for a day now) but I cant figure out what I'm doing wrong.
'O' and by the way, encase my question didn't make that apparent, I'm new at this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其更改为
您
需要实际创建
Movie
类的实例,这就是Movie()
的作用。 (您收到的错误消息中的关键字是“Movie
instance”。)Change it from
to
You need to actually make an instance of the
Movie
class, which is whatMovie()
does. (The key word in the error message you got was "Movie
instance".)