nodes: 0, module; 1, function_definition; 2, function_name:_final_redis_call; 3, parameters; 4, block; 5, identifier:self; 6, identifier:final_set; 7, identifier:sort_options; 8, expression_statement; 9, expression_statement; 10, comment:# we have a sorted set without need to sort, use zrange; 11, if_statement; 12, comment:# we have a stored collection, without other filter, and no need to; 13, comment:# sort, use lrange; 14, if_statement; 15, comment:# normal call; 16, return_statement; 17, comment:"""
          The final redis call to obtain the values to return from the "final_set"
          with some sort options.
          IIf we have at leaset a sorted set and if we don't have any sort
          options, call zrange on the final set wich is the result of a call to
          zinterstore.
          """; 18, assignment; 19, boolean_operator; 20, block; 21, boolean_operator; 22, block; 23, call; 24, identifier:conn; 25, call; 26, attribute; 27, comparison_operator:sort_options is None; 28, return_statement; 29, boolean_operator; 30, line_continuation:\; 31, parenthesized_expression; 32, return_statement; 33, attribute; 34, argument_list; 35, attribute; 36, argument_list; 37, identifier:self; 38, identifier:_has_sortedsets; 39, identifier:sort_options; 40, None; 41, call; 42, boolean_operator; 43, line_continuation:\; 44, comparison_operator:len(self._lazy_collection['intersects']) == 1; 45, boolean_operator; 46, call; 47, call; 48, identifier:_final_redis_call; 49, identifier:final_set; 50, identifier:sort_options; 51, attribute; 52, identifier:get_connection; 53, attribute; 54, argument_list; 55, attribute; 56, not_operator; 57, call; 58, integer:1; 59, comparison_operator:sort_options is None; 60, comparison_operator:sort_options == {'by': 'nosort'}; 61, attribute; 62, argument_list; 63, identifier:super; 64, argument_list; 65, identifier:self; 66, identifier:cls; 67, identifier:conn; 68, identifier:zrange; 69, identifier:final_set; 70, integer:0; 71, unary_operator; 72, identifier:self; 73, identifier:stored_key; 74, subscript; 75, identifier:len; 76, argument_list; 77, identifier:sort_options; 78, None; 79, identifier:sort_options; 80, dictionary; 81, identifier:conn; 82, identifier:lrange; 83, identifier:final_set; 84, integer:0; 85, unary_operator; 86, identifier:ExtendedCollectionManager; 87, identifier:self; 88, integer:1; 89, attribute; 90, string; 91, subscript; 92, pair; 93, integer:1; 94, identifier:self; 95, identifier:_lazy_collection; 96, string_content:sets; 97, attribute; 98, string; 99, string; 100, string; 101, identifier:self; 102, identifier:_lazy_collection; 103, string_content:intersects; 104, string_content:by; 105, string_content:nosort
code: def _final_redis_call(self, final_set, sort_options):
          """
          The final redis call to obtain the values to return from the "final_set"
          with some sort options.
          IIf we have at leaset a sorted set and if we don't have any sort
          options, call zrange on the final set wich is the result of a call to
          zinterstore.
          """
          conn = self.cls.get_connection()
  
          # we have a sorted set without need to sort, use zrange
          if self._has_sortedsets and sort_options is None:
  
              return conn.zrange(final_set, 0, -1)
  
          # we have a stored collection, without other filter, and no need to
          # sort, use lrange
          if self.stored_key and not self._lazy_collection['sets']\
                  and len(self._lazy_collection['intersects']) == 1\
                  and (sort_options is None or sort_options == {'by': 'nosort'}):
  
              return conn.lrange(final_set, 0, -1)
  
          # normal call
          return super(ExtendedCollectionManager, self)._final_redis_call(
                                                          final_set, sort_options)