Current File : //proc/self/root/lib/python3/dist-packages/twisted/web/__pycache__/_element.cpython-312.pyc |
�
Ϫ�f� � � � d dl Z d dlmZmZmZmZmZmZmZm Z d dl
mZ d dlm
Z
mZmZ d dlmZmZmZ erd dlmZmZ ed� Z eded ef �
� Z G d� d� Zd
ed ef defd�Zedd�� Z ee� G d� d� � Zy)� N)�
TYPE_CHECKING�Any�Callable�List�Optional�TypeVar�Union�overload)�implementer)�MissingRenderMethod�MissingTemplateLoader�UnexposedMethodError)�IRenderable�IRequest�ITemplateLoader)�Flattenable�Tag�T�_Tc.)�boundc � � e Zd ZdZdededef defd�Z e� Ze dede
dedef fd �� Ze dede
d
e
deedef e
f fd�� Zefdede
d
edefd�Zy
)�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.
�f�funcObjs.�returnc � � t j |g|� D ]- }t |dg � }|j | � t |d|� �/ |S )a;
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.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}.
�exposedThrough)� itertools�chain�getattr�append�setattr)�selfr r �fObjr s �6/usr/lib/python3/dist-packages/twisted/web/_element.py�__call__zExpose.__call__, sQ � �8 �O�O�Q�C��2� <�D�+2�4�9I�2�+N�N��!�!�$�'��D�*�N�;� <� �� �instance�
methodNamec � � y �N� )r# r( r) s r% �getz
Expose.getP s � �r'