title: Custom storage system in Django
body: <p>I'm trying to write a simple custom storage system.</p>
  
  <p>I need only that my storage system duplicate files from a few FTP servers.</p>
  
  <p>Subclass of storage looks like:</p>
  
  <pre><code>from django.core.files.storage import Storage
  from settings import MEDIA_ROOT, MEDIA_URL
  import ftplib
  import os
  
  
  
  class FTPStorage(Storage):
      """FTP Storage class for Django pluggable storage system."""
  
      def __init__(self, mediaroot=MEDIA_ROOT, base_url=MEDIA_URL):
          self._netrc=open('netrc')
          self._machine=[]
          self._login=[]
          self._password=[]
  
  
   def _save(self, name, content):
       content.open()
          if hasattr(content, 'chunks'):
              content_str = ''.join(chunk for chunk in content.chunks())
          else:
              content_str = content.read() 
          for line in netrc: #read netrc file
              old=line.strip()
              line=line.strip().split()
              if old.startswith("machine"): machine.append(line[-1])
              if old.startswith("login"): login.append(line[-1])
              if old.startswith("password"): password.append(line[-1])
          for i in range(len(machine)):
              try:
                 ftp = ftplib.FTP(machine[i])
                 ftp.login(login[i],password[i])
              except Exception,e:
                  print e
              else:
                  ftp.cwd("PublicFolder")
                  ftp.storbinary("STOR " + os.path.basename(name), StringIO(content_str), "rb", 8*1024)  
          return name
  </code></pre>
  
  <p>But now it give me the error:</p>
  
  <blockquote>
    <p>line:20, in __init__<br>
    if hasattr(content, 'chunks'):<br>
    Name error: Global name is not defined.</p>
  </blockquote>
  
  <p>Can I just write the <code>_save</code> method, so it'll work?</p>