def increment(handler): ''' This function is used to check the cache. Suppose we fetch a page, then Gramex is restarted, and we fetch it again. Gramex recomputes the results, which don't change. So the ETag will match the browser. Then Gramex returns a 304. This 304 must still be cached as a 200, with the correct result. ''' info.increment = 1 + info.get('increment', 0) return 'Constant result'
def sms_info(handler): result = {} for key, obj in info.get('sms', {}).items(): result[key] = {'cls': type(obj).__name__} result[key].update({k: str(v) for k, v in vars(obj).items()}) return result