# File lib/amazon/search.rb, line 307
      def initialize(dev_token=nil, associate=nil, locale=nil, cache=true,
                     user_agent = USER_AGENT)

        def_locale = locale
        locale = 'us' unless locale
        locale.downcase!

        configs = [ '/etc/amazonrc' ]
        configs << File.expand_path('~/.amazonrc') if ENV.key?('HOME')
        @config = {}

        configs.each do |config|
          if File.exists?(config) && File.readable?(config)
            Amazon::dprintf("Opening %s ...\n", config)

            File.open(config) { |f| lines = f.readlines }.each do |line|

              # Skip comments and blank lines
              next if line =~ /^(#|$)/

              Amazon::dprintf("Read: %s", line)

              # Store these, because we'll probably find a use for these later
              key, val = line.match(/^(\S+)\s*=\s*['"](\S+)['"]/)[1,2]
              @config[key] = val

              # Right now, we just evaluate the line, setting the variable if
              # it does not already exist
              eval line.sub(/=/, '||=')
            end
          end
        end

        # take locale from config file if no locale was passed to method
        locale = @config['locale'] if @config.key?('locale') && ! def_locale

        unless LOCALES.has_key? locale
          raise LocaleError, 'invalid locale'
        end

        if dev_token.nil?
          raise TokenError, 'dev_token may not be nil'
        end

        @token     = dev_token
        @id        = associate || DEFAULT_ID[locale]
        @conn      = Net::HTTP.start(LOCALES[locale])
        @locale            = locale
        @user_agent = user_agent
        @cache     = if cache
                        Amazon::Search::Cache.new(@config['cache_dir'] ||
                                                  '/tmp/amazon')
                      else
                        nil
                      end
      end