
    |h                     <    d dl mZ d dlmZ d dlmZ  G d d      Zy)    )i18n)WebobInputWrapper)	clean_keyc                   T    e Zd ZdZd Zd Zd ZdZdZdZ	dZ
dZd ZdZd	Zi Zd
 Zd Zy)DefaultMetaz
    This is the default Meta class which defines all the default values and
    therefore also the 'API' of the class Meta interface.
    c                 *     |j                   dd|i|S )a  
        bind_field allows potential customization of how fields are bound.

        The default implementation simply passes the options to
        :meth:`UnboundField.bind`.

        :param form: The form.
        :param unbound_field: The unbound field.
        :param options:
            A dictionary of options which are typically passed to the field.

        :return: A bound field
        form )bind)selfr	   unbound_fieldoptionss       K/var/www/html/test/engine/venv/lib/python3.12/site-packages/wtforms/meta.py
bind_fieldzDefaultMeta.bind_field   s     "}!!7t7w77    c                 f    |.t        |d      s"t        |d      rt        |      S t        d      |S )aZ  
        wrap_formdata allows doing custom wrappers of WTForms formdata.

        The default implementation detects webob-style multidicts and wraps
        them, otherwise passes formdata back un-changed.

        :param form: The form.
        :param formdata: Form data.
        :return: A form-input wrapper compatible with WTForms.
        getlistgetallzNformdata should be a multidict-type wrapper that supports the 'getlist' method)hasattrr   	TypeError)r   r	   formdatas      r   wrap_formdatazDefaultMeta.wrap_formdata   sA     )(Dx*(225  r   c                 &   |j                         D ci c]  \  }}t        |      | }}}t        |dd      }|8|j                         D ci c]  \  }}t        |      | }}}t        |fi |} |j                  |fi |S c c}}w c c}}w )z
        render_field allows customization of how widget rendering is done.

        The default implementation calls ``field.widget(field, **render_kw)``
        	render_kwN)itemsr   getattrdictwidget)r   fieldr   kvother_kws         r   render_fieldzDefaultMeta.render_field3   s     2;1BCAYq\1_C	C5+t44<NN4DEDAq	!aEHEX33Iu||E/Y// D Fs   BBF
csrf_tokenNc                 T    | j                   | j                         S ddlm}  |       S )a  
        Build a CSRF implementation. This is called once per form instance.

        The default implementation builds the class referenced to by
        :attr:`csrf_class` with zero arguments. If `csrf_class` is ``None``,
        will instead use the default implementation
        :class:`wtforms.csrf.session.SessionCSRF`.

        :param form: The form.
        :return: A CSRF implementation.
        r   )SessionCSRF)
csrf_classwtforms.csrf.sessionr&   )r   r	   r&   s      r   
build_csrfzDefaultMeta.build_csrfJ   s&     ??&??$$4}r   Tc                 
   | j                   }|du ry| j                  rR|rt        |      nd}| j                  j	                  |      }|$t        j                  |      x}| j                  |<   |S t        j                  |      S )z
        Override in subclasses to provide alternate translations factory.
        See the i18n documentation for more.

        :param form: The form.
        :return: An object that provides gettext() and ngettext() methods.
        FN)localescache_translationstupletranslations_cachegetr   get_translations)r   r	   r+   translationss       r   r0   zDefaultMeta.get_translationsc   s     ,,e""(/eGnTG2266w?L#BFBWBWC t66w?  $$W--r   c                 N    |j                         D ]  \  }}t        | ||        y)zV
        Given a dictionary of values, update values on this `Meta` instance.
        N)r   setattr)r   valueskeyvalues       r   update_valueszDefaultMeta.update_values   s)     !,,. 	&JCD#u%	&r   )__name__
__module____qualname____doc__r   r   r#   csrfcsrf_field_namecsrf_secretcsrf_contextr'   r)   r+   r,   r.   r0   r7   r
   r   r   r   r      sS    8 *0" D"OKLJ* G.8&r   r   N)wtformsr   wtforms.utilsr   wtforms.widgets.corer   r   r
   r   r   <module>rC      s     + *~& ~&r   