Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

backwards compatibility support for FeedExport's that don't receive a settings object in their constructor

Pablo Hoffman251d9a9033ae
diff --git a/scrapy/contrib/feedexport.py b/scrapy/contrib/feedexport.py
index 6f8b272f0..988ecdfd6 100644
--- a/scrapy/contrib/feedexport.py
+++ b/scrapy/contrib/feedexport.py
@@ -18,6 +18,7 @@ from scrapy import log, signals
from scrapy.utils.ftp import ftp_makedirs_cwd
from scrapy.exceptions import NotConfigured
from scrapy.utils.misc import load_object
+from scrapy.utils.python import get_func_args
class IFeedStorage(Interface):
@@ -133,7 +134,6 @@ class SpiderSlot(object):
class FeedExporter(object):
def __init__(self, settings):
- self.settings = settings
self.urifmt = settings['FEED_URI']
if not self.urifmt:
raise NotConfigured
@@ -151,7 +151,15 @@ class FeedExporter(object):
@classmethod
def from_crawler(cls, crawler):
- o = cls(crawler.settings)
+ if len(get_func_args(cls)) < 1:
+ # FIXME: remove for scrapy 0.17
+ import warnings
+ from scrapy.exceptions import ScrapyDeprecationWarning
+ warnings.warn("%s must receive a settings object as first constructor argument." % cls.__name__,
+ ScrapyDeprecationWarning, stacklevel=2)
+ o = cls()
+ else:
+ o = cls(crawler.settings)
crawler.signals.connect(o.open_spider, signals.spider_opened)
crawler.signals.connect(o.close_spider, signals.spider_closed)
crawler.signals.connect(o.item_scraped, signals.item_scraped)