def publish(self): # cache ourselves so that we're ready for .cached.get(pk=) self.publish_by('pk') # find any @cached_methods with auto_publish=True for method in find_fields_decorated_with(self, '_cached_method'): if not getattr(method, '_cached_method_auto_publish', False): continue try: # run the cached method and store it in cache self.publish_method(method.__name__) except TypeError as e: # the @cached_method requires arguments, so we cant cache it automatically pass
def denormalize(self): for method in find_fields_decorated_with(self, '_denormalized_field'): if hasattr(method, '_denormalized_field_name'): setattr(self, method._denormalized_field_name, method(self))