def _insert_links(data_dict, limit, offset):
 data_dict['_links'] = {}
 try:
  urlstring = toolkit.request.environ['CKAN_CURRENT_URL']
 except (KeyError, TypeError):
  return
 parsed = list(urlparse.urlparse(urlstring))
 query = urllib2.unquote(parsed[4])
 arguments = dict(urlparse.parse_qsl(query))
 arguments_start = dict(arguments)
 arguments_prev = dict(arguments)
 arguments_next = dict(arguments)
 if ('offset' in arguments_start):
  arguments_start.pop('offset')
 arguments_next['offset'] = (int(offset) + int(limit))
 arguments_prev['offset'] = (int(offset) - int(limit))
 parsed_start = parsed[:]
 parsed_prev = parsed[:]
 parsed_next = parsed[:]
 parsed_start[4] = urllib.urlencode(arguments_start)
 parsed_next[4] = urllib.urlencode(arguments_next)
 parsed_prev[4] = urllib.urlencode(arguments_prev)
 data_dict['_links']['start'] = urlparse.urlunparse(parsed_start)
 data_dict['_links']['next'] = urlparse.urlunparse(parsed_next)
 if ((int(offset) - int(limit)) > 0):
  data_dict['_links']['prev'] = urlparse.urlunparse(parsed_prev)

def _insert_links ( data_dict , limit , offset ) : data_dict [ '_links' ] = { } try : urlstring = toolkit . request . environ [ 'CKAN_CURRENT_URL' ] except ( KeyError , TypeError ) : return parsed = list ( urlparse . urlparse ( urlstring ) ) query = urllib2 . unquote ( parsed [ 4 ] ) arguments = dict ( urlparse . parse_qsl ( query ) ) arguments_start = dict ( arguments ) arguments_prev = dict ( arguments ) arguments_next = dict ( arguments ) if ( 'offset' in arguments_start ) : arguments_start . pop ( 'offset' ) arguments_next [ 'offset' ] = ( int ( offset ) + int ( limit ) ) arguments_prev [ 'offset' ] = ( int ( offset ) - int ( limit ) ) parsed_start = parsed [ : ] parsed_prev = parsed [ : ] parsed_next = parsed [ : ] parsed_start [ 4 ] = urllib . urlencode ( arguments_start ) parsed_next [ 4 ] = urllib . urlencode ( arguments_next ) parsed_prev [ 4 ] = urllib . urlencode ( arguments_prev ) data_dict [ '_links' ] [ 'start' ] = urlparse . urlunparse ( parsed_start ) data_dict [ '_links' ] [ 'next' ] = urlparse . urlunparse ( parsed_next ) if ( ( int ( offset ) - int ( limit ) ) > 0 ) : data_dict [ '_links' ] [ 'prev' ] = urlparse . urlunparse ( parsed_prev )
adds link to the next/prev part and the resource page .