ó
Vü½cc           @   s‹   d  Z  d d l Z d d l m Z m Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d Z d	 Z d
 d d „  ƒ  YZ d S(   s&   Base class for all web GUI components.iÿÿÿÿN(   t	   TupleTypet   ListType(   t   mm_cfg(   t   Utils(   t   Errors(   t   _s   
s   </code>, <code>t   GUIBasec           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c   
      C   sM  | t  j t  j f k r" t | ƒ S| t  j t  j f k r> | S| t  j k rg | rc t j | ƒ n  | S| t  j	 t  j
 f k r6t | t ƒ r’ | Sg  } g  } xsg  | j t ƒ D] } | j ƒ  ^ q± D]I} | sÙ qÇ n  y t j | ƒ WnÙ t j k
 rÅ| t  j
 k rS| j d ƒ rSy t j | ƒ WqÂt j k
 rO| j | ƒ qÂXqÆ| t  j
 k rµ| j d ƒ rµ| j d ƒ sŒ| d k rµ| d | j ƒ  k rÂ| j | ƒ qÂqÆ| j | ƒ n X| d k r| j ƒ  | j ƒ  j ƒ  k r| j | ƒ qn  | j | ƒ qÇ W| r2t j d j | ƒ ‚ n  | S| t  j k rI| S| t  j k r¾t | t ƒ rk| Sd	 }	 y t | ƒ }	 Wn t k
 r t | ƒ }	 n X|	 d
 k  rºt  | | ƒ S|	 S| t  j! k rÑ| S| t  j" k rút | t ƒ ró| S| g S| t  j# k r| S| t  j$ k r | S| t  j% k r3| Sd
 sIt& d | ƒ ‚ d  S(   Nt   ^t   @t   _these_nonmemberst   subscribe_auto_approvali   t   regular_exclude_listst   regular_include_listss   , iÿÿÿÿi    s   Bad gui widget type: %s(   R   R   ('   R   t   Radiot   Togglet   intt   Stringt   Textt   EmailR   t   ValidateEmailt	   EmailListt   EmailListExt
   isinstanceR   t   splitt   NLt   stripR   t   EmailAddressErrort
   startswitht   ret   compilet   errort   appendt   endswitht   internal_namet   lowert   GetListEmailt   joint   Hostt   Numbert   floatt
   ValueErrort   getattrt   Selectt   Checkboxt
   FileUploadt   Topicst   HeaderFiltert   AssertionError(
   t   selft   mlistt   propertyt   wtypet   valt   addrst	   bad_addrst   st   addrt   num(    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyt   _getValidValue&   s€    
/	c         C   s<   | j  d ƒ r8 t | | ƒ | k r8 t | | | ƒ n  d  S(   NR   (   R   R)   t   setattr(   R0   R1   R2   R4   t   doc(    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyt	   _setValueŠ   s    %c         C   s   d  S(   N(    (   R0   R1   R<   (    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyt   _postValidate   s    c         C   sœ  x…|  j  | | | ƒ D]n} t | t ƒ s t | ƒ d k  rD q n  | d d !\ } } }	 }
 } | d } | j | ƒ r– | | j r– | | j } nX | j | ƒ s« q nC t | | t ƒ rá g  | | D] } | j ^ qÉ } n | | j } y |  j | | | | ƒ } Wna t k
 r0| j	 t
 d ƒ ƒ q t j k
 rm} t j t | ƒ ƒ } | j	 t
 d ƒ ƒ q X|  j | | | | ƒ q W|  j | | ƒ d  S(   Ni   i    t   _uploads(   Invalid value for variable: %(property)ss4   Bad email address for option %(property)s: %(error)s(   t   GetConfigInfoR   R    t   lent   has_keyt   valueR   R:   R(   t   addErrorR   R   R   R   t   websafet   strR=   R>   (   R0   R1   t   categoryt   subcatt   cgidataR<   t   itemR2   R3   t   argst   depst   desct
   uploadpropR4   t   xR   (    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyt
   handleForm“   s,    "
#c         C   sù   t  | d d ƒ } | r* t j | ƒ } n t j | ƒ } x' | D] } | j | ƒ r@ | | =q@ q@ W| r± | j ƒ  }	 |	 j ƒ  t j |	 ƒ }
 | j	 t
 d ƒ d t
 d ƒ ƒ| S| sõ t j t j | ƒ ƒ } | | k rõ | j	 t
 d ƒ ƒ | Sn  | S(   Nt   use_dollar_stringsi    sû   The following illegal substitution variables were
                found in the <code>%(property)s</code> string:
                <code>%(bad)s</code>
                <p>Your list may not operate properly until you correct this
                problem.t   tags	   Warning: s  Your <code>%(property)s</code> string appeared to
                    have some correctable problems in its new value.
                    The fixed value will be used instead.  Please
                    double check that this is what you intended.
                    (   R)   R   t   dollar_identifierst   percent_identifiersRB   t   keyst   sortt	   BADJOINERR$   RD   R   t
   to_percentt	   to_dollar(   R0   R1   R2   t   allowedsR4   R<   t   dollarpt   idst   allowedt   badkeyst   badt   fixed(    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyt   _convertString»   s*    
		
(   t   __name__t
   __module__R:   R=   R>   RP   Ra   (    (    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyR   !   s
   	d			((    (   t   __doc__R   t   typesR    R   t   MailmanR   R   R   t   Mailman.i18nR   R   RW   R   (    (    (    s2   /export/web/mailman/mailman/Mailman/Gui/GUIBase.pyt   <module>   s   