'Retain certain GET vars of the request in action links
@param r: the S3Request
@return: Storage with GET vars'

@staticmethod
def _linkto_vars(r):

    get_vars = r.get_vars
    linkto_vars = Storage()
    if ((not r.component) and ('viewing' in get_vars)):
        linkto_vars.viewing = get_vars['viewing']
    keep_vars = current.response.s3.crud.keep_vars
    if keep_vars:
        for key in keep_vars:
            if (key in get_vars):
                linkto_vars[key] = get_vars[key]
    return linkto_vars
