Skip to content

Instantly share code, notes, and snippets.

@jeremi
Created December 12, 2010 09:19
Show Gist options
  • Save jeremi/737950 to your computer and use it in GitHub Desktop.
Save jeremi/737950 to your computer and use it in GitHub Desktop.
This decorator restore the original namespace after the function has been executed in appengine.
def restore_namespace_after(func):
"""Decorator that ensures that restore the original namespace after the function has
been executed in appengine."""
@functools.wraps(func)
def decorated_func(*args, **kwargs):
namespace = namespace_manager.get_namespace()
res = func(*args, **kwargs)
namespace_manager.set_namespace(namespace)
return res
return decorated_func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment