Merge pull request #168 from alexcepoi/parse-fixes

parse command: fix crash in case of bad callback
This commit is contained in:
Pablo Hoffman 2012-08-31 09:12:19 -07:00
commit a2d5a304b1
1 changed files with 8 additions and 3 deletions

View File

@ -152,9 +152,14 @@ class Command(ScrapyCommand):
else:
cb = 'parse'
cb = cb if callable(cb) else getattr(self.spider, cb, None)
if not cb:
log.msg('Cannot find callback %r in spider: %s' % (callback, self.spider.name))
if not callable(cb):
cb_method = getattr(self.spider, cb, None)
if callable(cb_method):
cb = cb_method
else:
log.msg('Cannot find callback %r in spider: %s' % \
(cb, self.spider.name), level=log.ERROR)
return
# parse items and requests
depth = response.meta['_depth']