def cache_page(*args, **kwargs):
 cache_alias = kwargs.pop('cache', None)
 key_prefix = kwargs.pop('key_prefix', None)
 assert (not kwargs), 'The only keyword arguments are cache and key_prefix'
 def warn():
  import warnings
  warnings.warn('The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated.', PendingDeprecationWarning, stacklevel=3)
 if (len(args) > 1):
  assert (len(args) == 2), 'cache_page accepts at most 2 arguments'
  warn()
  if callable(args[0]):
   return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[1], cache_alias=cache_alias, key_prefix=key_prefix)(args[0])
  elif callable(args[1]):
   return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[0], cache_alias=cache_alias, key_prefix=key_prefix)(args[1])
  else:
   assert False, 'cache_page must be passed a view function if called with two arguments'
 elif (len(args) == 1):
  if callable(args[0]):
   warn()
   return decorator_from_middleware_with_args(CacheMiddleware)(cache_alias=cache_alias, key_prefix=key_prefix)(args[0])
  else:
   return decorator_from_middleware_with_args(CacheMiddleware)(cache_timeout=args[0], cache_alias=cache_alias, key_prefix=key_prefix)
 else:
  warn()
  return decorator_from_middleware_with_args(CacheMiddleware)(cache_alias=cache_alias, key_prefix=key_prefix)

def cache_page ( * args , ** kwargs ) : cache_alias = kwargs . pop ( 'cache' , None ) key_prefix = kwargs . pop ( 'key_prefix' , None ) assert ( not kwargs ) , 'The only keyword arguments are cache and key_prefix' def warn ( ) : import warnings warnings . warn ( 'The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated.' , PendingDeprecationWarning , stacklevel = 3 ) if ( len ( args ) > 1 ) : assert ( len ( args ) == 2 ) , 'cache_page accepts at most 2 arguments' warn ( ) if callable ( args [ 0 ] ) : return decorator_from_middleware_with_args ( CacheMiddleware ) ( cache_timeout = args [ 1 ] , cache_alias = cache_alias , key_prefix = key_prefix ) ( args [ 0 ] ) elif callable ( args [ 1 ] ) : return decorator_from_middleware_with_args ( CacheMiddleware ) ( cache_timeout = args [ 0 ] , cache_alias = cache_alias , key_prefix = key_prefix ) ( args [ 1 ] ) else : assert False , 'cache_page must be passed a view function if called with two arguments' elif ( len ( args ) == 1 ) : if callable ( args [ 0 ] ) : warn ( ) return decorator_from_middleware_with_args ( CacheMiddleware ) ( cache_alias = cache_alias , key_prefix = key_prefix ) ( args [ 0 ] ) else : return decorator_from_middleware_with_args ( CacheMiddleware ) ( cache_timeout = args [ 0 ] , cache_alias = cache_alias , key_prefix = key_prefix ) else : warn ( ) return decorator_from_middleware_with_args ( CacheMiddleware ) ( cache_alias = cache_alias , key_prefix = key_prefix )
decorator for views that tries getting the page from the cache and populates the cache if the page isnt in the cache yet .