title: Scrapy - Get spider variables inside DOWNLOAD MIDDLEWARE __init__
body: <p>I'm working on a Scrapy project, on which I wrote a DOWNLOADER MIDDLEWARE to avoid making requests to URLs that are already on the database.</p>
  
  <pre><code>DOWNLOADER_MIDDLEWARES = {
     'imobotS.utilities.RandomUserAgentMiddleware': 400,
     'imobotS.utilities.DupFilterMiddleware': 500,
     'scrapy.contrib.downloadermiddleware.useragent.UserAgentMiddleware': None,
  }
  </code></pre>
  
  <p>The idea is to connect and load on <strong>__init__</strong> a distinct list of all the urls currently stored on DB, and raise IgnoreRequests if the scraped item is already on DB.</p>
  
  <pre><code>class DuplicateFilterMiddleware(object):
  
      def __init__(self):
          connection = pymongo.Connection('localhost', 12345)
          self.db = connection['my_db']
          self.db.authenticate('scott', '*****')
  
          self.url_set = self.db.ad.find({'site': 'WEBSITE_NAME'}).distinct('url')
  
      def process_request(self, request, spider):
          print "%s - process Request URL: %s" % (spider._site_name, request.url)
          if request.url in self.url_set:
              raise IgnoreRequest("Duplicate --db-- item found: %s" % request.url)
          else:
              return None
  </code></pre>
  
  <p>So, as I want to restrict the url_list defined on init by WEBSITE_NAME, is there a way to identify the current spider name inside the Download Middleware <strong>__init__</strong> method?</p>