File: //lib/python3/dist-packages/twisted/web/__pycache__/_element.cpython-38.pyc
U
W[; � @ s� d dl mZmZ d dlmZ d dlmZ d dlmZm Z d dlm
Z
G dd� de�Zej
Zedd � �Zee�G d
d� de��ZdS )
� )�division�absolute_import)�implementer)�IRenderable)�MissingRenderMethod�UnexposedMethodError)�MissingTemplateLoaderc @ s@ e Zd ZdZddd�Zdd� Ze� Zefdd�Ze d d
� �Z
dS )�Exposea�
Helper for exposing methods for various uses using a simple decorator-style
callable.
Instances of this class can be called with one or more functions as
positional arguments. The names of these functions will be added to a list
on the class object of which they are methods.
@ivar attributeName: The attribute with which exposed methods will be
tracked.
Nc C s
|| _ d S �N)�doc)�selfr � r
�6/usr/lib/python3/dist-packages/twisted/web/_element.py�__init__ s zExpose.__init__c G s8 |st d��|D ]}t|dg �|_|j�| � q|d S )aH
Add one or more functions to the set of exposed functions.
This is a way to declare something about a class definition, similar to
L{zope.interface.declarations.implementer}. Use it like this::
magic = Expose('perform extra magic')
class Foo(Bar):
def twiddle(self, x, y):
...
def frob(self, a, b):
...
magic(twiddle, frob)
Later you can query the object::
aFoo = Foo()
magic.get(aFoo, 'twiddle')(x=1, y=2)
The call to C{get} will fail if the name it is given has not been
exposed using C{magic}.
@param funcObjs: One or more function objects which will be exposed to
the client.
@return: The first of C{funcObjs}.
z,expose() takes at least 1 argument (0 given)�exposedThroughr )� TypeError�getattrr �append)r ZfuncObjsZfObjr
r
r �__call__ s zExpose.__call__c C s<