    # File lib/chef/environment.rb, line 337
        def self.cdb_load_filtered_cookbook_versions(name, couchdb=nil)
          version_constraints = cdb_load(name, couchdb).cookbook_versions.inject({}) {|res, (k,v)| res[k] = Chef::VersionConstraint.new(v); res}

          # inject all cookbooks into the hash while filtering out restricted versions, then sort the individual arrays
          cookbook_list = Chef::CookbookVersion.cdb_list(true, couchdb)

          filtered_list = cookbook_list.inject({}) do |res, cookbook|
            # FIXME: should cookbook.version return a Chef::Version?
            version               = Chef::Version.new(cookbook.version)
            requirement_satisfied = version_constraints.has_key?(cookbook.name) ? version_constraints[cookbook.name].include?(version) : true
            # we want a key for every cookbook, even if no versions are available
            res[cookbook.name] ||= []
            res[cookbook.name] << cookbook if requirement_satisfied
            res
          end

          sorted_list = filtered_list.inject({}) do |res, (cookbook_name, versions)|
            res[cookbook_name] = versions.sort.reverse
            res
          end

          sorted_list
        end