def stash_utm_params(session: SessionBase, params: UtmParamsDict) -> bool: """ Add new utm_params to the list of utm_params in the session. If the params dict is empty ({}), then it is ignored. Returns True if the params are stored, else False. """ if params: session.setdefault(SESSION_KEY_UTM_PARAMS, []) session[SESSION_KEY_UTM_PARAMS].append(params) return True return False
def stash_utm_params(session: SessionBase, params: UtmParamsDict) -> bool: """ Add new utm_params to the list of utm_params in the session. If the params dict is empty ({}), or already stashed in the session, then it's ignored. Returns True if the params are stored. """ if not params: return False session.setdefault(SESSION_KEY_UTM_PARAMS, []) if params in session[SESSION_KEY_UTM_PARAMS]: return False session[SESSION_KEY_UTM_PARAMS].append(params) # because we are adding to a list, we are not actually changing the # session object itself, so we need to force it to be saved. session.modified = True return True