def value_for(self, field): """Give the value for the field (attribute). 1. Get it from the request. 2. Get it from the cookie. 3. Empty. """ if not self.request.get('clearcookies'): from_req = self.request.get(field, None) if from_req is not None: return from_req cookie_string = self.request.cookies.get(self.cookiename, None) if cookie_string is None: return '' cookie_dict = parse_attribute_cookie(cookie_string) return cookie_dict.get(field, '')
def _parseAttributeCookie(self, cookiestring): """Parse the attribute cookie. """ return parse_attribute_cookie(cookiestring)