From 5babbaf48a71af786d41f59a1f1f7d5272a60a4d Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 17 Dec 2009 01:17:48 +0000 Subject: - When Chameleon page or text templates were added imperatively (via ``Configurator.add_view`` or some derivative), they too-eagerly attempted to look up the ``reload_templates`` setting via ``get_settings``, meaning they were always registered in non-auto-reload-mode (the default). Each now waits until its respective ``template`` attribute is accessed to look up the value. --- repoze/bfg/decorator.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 repoze/bfg/decorator.py (limited to 'repoze/bfg/decorator.py') diff --git a/repoze/bfg/decorator.py b/repoze/bfg/decorator.py new file mode 100644 index 000000000..69c1e65e2 --- /dev/null +++ b/repoze/bfg/decorator.py @@ -0,0 +1,15 @@ +class reify(object): + + """ Put the result of a method which uses this (non-data) + descriptor decorator in the instance dict after the first call, + effectively replacing the decorator with an instance variable.""" + + def __init__(self, wrapped): + self.wrapped = wrapped + + def __get__(self, inst, objtype=None): + if inst is None: + return self + val = self.wrapped(inst) + setattr(inst, self.wrapped.__name__, val) + return val -- cgit v1.2.3