From 948cc8a14d334ce696e58530b006e39d4dcfa9b4 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 19 Jun 2009 22:25:59 +0000 Subject: Move pushpage support out into separate distribution. --- repoze/bfg/push.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 repoze/bfg/push.py (limited to 'repoze/bfg/push.py') diff --git a/repoze/bfg/push.py b/repoze/bfg/push.py deleted file mode 100644 index 1e60b7e94..000000000 --- a/repoze/bfg/push.py +++ /dev/null @@ -1,40 +0,0 @@ -import os.path - -from repoze.bfg.chameleon_zpt import render_template_to_response - -try: - from functools import wraps -except ImportError: #pragma NO COVERAGE - # < 2.5 - from repoze.bfg.functional import wraps #pragma NO COVERAGE - -class pushpage(object): - """ - Decorator for a function which returns a response object after - running the namespace the wrapped function returns through a - Chameleon ZPT template. - - E.g.:: - - @pushpage('www/my_template.pt') - def my_view(context, request): - return {'a': 1, 'b': ()} - - Equates to:: - - from repoze.bfg.chameleon_zpt import render_template_to_response - def my_view(context, request): - return render_template_to_response('www/my_template.pt', a=1, b=()) - - """ - def __init__(self, template): - self.template = template - - def __call__(self, wrapped): - prefix = os.path.dirname(wrapped.func_globals['__file__']) - path = os.path.join(prefix, self.template) - - def _curried(context, request): - kw = wrapped(context, request) - return render_template_to_response(path, **kw) - return wraps(wrapped)(_curried) # grokkability -- cgit v1.2.3