@contextfunction
def htsortlink(context, field_name):
 if ('request' not in context):
  return ''
 request = context['request']
 sort_value = field_name
 url = (u'%s?' % request.path)
 if request.GET:
  for arg in request.GET:
   values = request.GET.getlist(arg)
   for value in values:
    svalue = value.lstrip('-')
    if ((arg == 'sorting') and (svalue == field_name)):
     if (value[0] != '-'):
      sort_value = (u'-%s' % sort_value)
    else:
     url += (((unicode(arg) + '=') + value) + '&')
 url += ('sorting=%s' % sort_value)
 return url

@ contextfunction def htsortlink ( context , field_name ) : if ( 'request' not in context ) : return '' request = context [ 'request' ] sort_value = field_name url = ( u'%s?' % request . path ) if request . GET : for arg in request . GET : values = request . GET . getlist ( arg ) for value in values : svalue = value . lstrip ( '-' ) if ( ( arg == 'sorting' ) and ( svalue == field_name ) ) : if ( value [ 0 ] != '-' ) : sort_value = ( u'-%s' % sort_value ) else : url += ( ( ( unicode ( arg ) + '=' ) + value ) + '&' ) url += ( 'sorting=%s' % sort_value ) return url
return url of the sorting field .