Beispiel #1
0
    def __getattr__(self, key):
        if self.callables and key in self.callables:
            return self.callables[key]

        if self.template and self.template.has_def(key):
            callable_ = self.template._get_def_callable(key)
            return util.partial(callable_, self.context)

        if self._module and hasattr(self._module, key):
            callable_ = getattr(self._module, key)
            return util.partial(callable_, self.context)

        if self.inherits is not None:
            return getattr(self.inherits, key)
        raise AttributeError(
                    "Namespace '%s' has no member '%s'" % 
                    (self.name, key))
Beispiel #2
0
 def __getattr__(self, key):
     if key in self.callables:
         val = self.callables[key]
     elif hasattr(self.module, key):
         callable_ = getattr(self.module, key)
         val = util.partial(callable_, self.context)
     elif self.inherits:
         val = getattr(self.inherits, key)
     else:
         raise AttributeError("Namespace '%s' has no member '%s'" %
                              (self.name, key))
     setattr(self, key, val)
     return val
Beispiel #3
0
 def __getattr__(self, key):
     if key in self.callables:
         val = self.callables[key]
     elif hasattr(self.module, key):
         callable_ = getattr(self.module, key)
         val = util.partial(callable_, self.context)
     elif self.inherits:
         val = getattr(self.inherits, key)
     else:
         raise AttributeError(
                 "Namespace '%s' has no member '%s'" % 
                 (self.name, key))
     setattr(self, key, val)
     return val
Beispiel #4
0
    def __init__(self, buffer, **data):
        self._buffer_stack = [buffer]
 
        self._data = data
        self._kwargs = data.copy()
        self._with_template = None
        self._outputting_as_unicode = None
        self.namespaces = {}
 
        # "capture" function which proxies to the 
        # generic "capture" function
        self._data['capture'] = util.partial(capture, self)
 
        # "caller" stack used by def calls with content
        self.caller_stack = self._data['caller'] = CallerStack()
Beispiel #5
0
    def __init__(self, buffer, **data):
        self._buffer_stack = [buffer]
 
        self._data = data
        self._kwargs = data.copy()
        self._with_template = None
        self._outputting_as_unicode = None
        self.namespaces = {}
 
        # "capture" function which proxies to the 
        # generic "capture" function
        self._data['capture'] = util.partial(capture, self)
 
        # "caller" stack used by def calls with content
        self.caller_stack = self._data['caller'] = CallerStack()
Beispiel #6
0
 def __init__(self, buffer, **data):
     self._buffer_stack = [buffer]
     
     # original data, minus the builtins
     self._orig = data
     
     # the context data which includes builtins
     self._data = __builtin__.__dict__.copy()
     self._data.update(data)
     self._kwargs = data.copy()
     self._with_template = None
     self._outputting_as_unicode = None
     self.namespaces = {}
     
     # "capture" function which proxies to the 
     # generic "capture" function
     self._data['capture'] = util.partial(capture, self)
     
     # "caller" stack used by def calls with content
     self.caller_stack = self._data['caller'] = CallerStack()
Beispiel #7
0
 def get(key):
     callable_ = getattr(self.module, key)
     return util.partial(callable_, self.context)
Beispiel #8
0
 def get(key):
     callable_ = self.template._get_def_callable(key)
     return util.partial(callable_, self.context)
Beispiel #9
0
 def get(key):
     callable_ = getattr(self.module, key)
     return util.partial(callable_, self.context)
Beispiel #10
0
 def get(key):
     callable_ = self.template._get_def_callable(key)
     return util.partial(callable_, self.context)