Scrapy, a fast high-level web crawling & scraping framework for Python.
change settings middleware name and updating middleware template
muriloviana34f2014c55ed
diff --git a/scrapy/commands/startproject.py b/scrapy/commands/startproject.pyindex 1001b8682..594106632 100644--- a/scrapy/commands/startproject.py+++ b/scrapy/commands/startproject.py@@ -17,7 +17,7 @@ TEMPLATES_TO_RENDER = (('${project_name}', 'settings.py.tmpl'),('${project_name}', 'items.py.tmpl'),('${project_name}', 'pipelines.py.tmpl'),- ('${project_name}', 'middleware.py.tmpl'),+ ('${project_name}', 'middlewares.py.tmpl'),)IGNORE = ignore_patterns('*.pyc', '.svn')diff --git a/scrapy/templates/project/module/middleware.py.tmpl b/scrapy/templates/project/module/middleware.py.tmpldeleted file mode 100644index 0ae9d7160..000000000--- a/scrapy/templates/project/module/middleware.py.tmpl+++ /dev/null@@ -1,23 +0,0 @@-# -*- coding: utf-8 -*---# Define here the models for your spider middleware-#-# See documentation in:-# http://doc.scrapy.org/en/latest/topics/spider-middleware.html---class ${ProjectName}SpiderMiddleware(object):- # This method is called for each response that goes through the- # spider middleware and into the spider, for processing.-- def process_spider_input(response, spider):- # Called for each response that goes to spider- pass-- def process_spider_output(response, result, spider):- # Called for each response with the spider results- pass-- def process_spider_exception(response, exception, spider):- # Called whenever a spider raises an exception- passdiff --git a/scrapy/templates/project/module/middlewares.py.tmpl b/scrapy/templates/project/module/middlewares.py.tmplnew file mode 100644index 000000000..91d05baa6--- /dev/null+++ b/scrapy/templates/project/module/middlewares.py.tmpl@@ -0,0 +1,39 @@+# -*- coding: utf-8 -*-++# Define here the models for your spider middleware+#+# See documentation in:+# http://doc.scrapy.org/en/latest/topics/spider-middleware.html+++class ${ProjectName}SpiderMiddleware(object):++ def process_spider_input(response, spider):+ # Called for each response that goes through the spider+ # middleware and into the spider.++ # Should return None or raise an exception.+ pass++ def process_spider_output(response, result, spider):+ # Called with the results returned from the Spider, after+ # it has processed the response.++ # Must return an iterable of Request, dict or Item objects.+ pass++ def process_spider_exception(response, exception, spider):+ # Called when a spider or process_spider_input() method+ # (from other spider middleware) raises an exception.++ # Should return either None or an iterable of Response, dict+ # or Item objects.+ pass++ def process_start_requests(start_requests, spider):+ # Called with the start requests of the spider, and works+ # similarly to the process_spider_output() method, except+ # that it doesn’t have a response associated.++ # Must return only requests (not items).+ passdiff --git a/scrapy/templates/project/module/settings.py.tmpl b/scrapy/templates/project/module/settings.py.tmplindex f13e85871..72f25ebef 100644--- a/scrapy/templates/project/module/settings.py.tmpl+++ b/scrapy/templates/project/module/settings.py.tmpl@@ -47,7 +47,7 @@ ROBOTSTXT_OBEY = True# Enable or disable spider middlewares# See http://scrapy.readthedocs.org/en/latest/topics/spider-middleware.html#SPIDER_MIDDLEWARES = {-# '$project_name.middlewares.MyCustomSpiderMiddleware': 543,+# '$project_name.middlewares.${ProjectName}SpiderMiddleware': 543,#}# Enable or disable downloader middlewares