Ñò
?]Mc        
   @   sÑ   d  Z  d d k Z d d k l Z l Z d d k l Z d d k l Z d d k l Z d d k	 l
 Z
 d d k l Z d d	 k l Z d
 „  Z d „  Z g  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   sR  Routines which rectify an old mailing list with current structure.

The MailList.CheckVersion() method looks for an old .data_version setting in
the loaded structure, and if found calls the Update() routine from this
module, supplying the list and the state last loaded from storage.  The state
is necessary to distinguish from default assignments done in the .InitVars()
methods, before .CheckVersion() is called.

For new versions you should add sections to the UpdateOldVars() and the
UpdateOldUsers() sections, to preserve the sense of settings across structural
changes.  Note that the routines have only one pass - when .CheckVersions()
finds a version change it runs this routine and then updates the data_version
number of the list, and then does a .Save(), so the transformations won't be
run again until another version change is detected.
iÿÿÿÿN(   t   ListTypet
   StringType(   t   mm_cfg(   t   Utils(   t   Message(   t   _BounceInfo(   t   UNKNOWN(   t   syslogc         C   sC   t  |  ƒ t |  ƒ t |  ƒ t |  | ƒ t |  ƒ t |  ƒ d S(   sH   Dispose of old vars and user options, mapping to new ones when suitable.N(   t
   ZapOldVarst   UpdateOldUserst   NewVarst   UpdateOldVarst   CanonicalizeUserOptionst   NewRequestsDatabase(   t   lt   stored_state(    (    s$   /usr/lib/mailman/Mailman/versions.pyt   Update1   s    



c      
   C   s6   x/ d D]' } t  |  | ƒ o t |  | ƒ q q Wd  S(   Nt
   num_spawnst   filter_progt   clobber_datet   public_archive_file_dirt   private_archive_file_dirt   archive_directoryt   minimum_removal_datet'   minimum_post_count_before_bounce_actiont   automatic_bounce_actiont   max_posts_between_bounces(
   R   R   R   R   R   R   R   R   R   R   (   t   hasattrt   delattr(   t   mlistt   name(    (    s$   /usr/lib/mailman/Mailman/versions.pyR   <   s          c         C   s  t  |  | d „ } t |  d ƒ o7 t |  d ƒ } t |  d ƒ p | |  _ n |  ` n t |  d ƒ p t i |  _ n t |  d ƒ p g  |  _ n t |  d ƒ p g  |  _	 n t |  d ƒ p g  |  _
 n t |  d ƒ p g  |  _ n t |  d	 ƒ p t i |  _ n t |  d
 ƒ p t i |  _ n t |  d ƒ oö|  i o„ x5 |  i D]* } |  i | ƒ p |  i i | ƒ qQqQWx3 |  i ƒ  D]% } |  i | t i | |  i j ƒ qŒWd |  _ d |  _ nS|  i o{ x5 |  i D]* } |  i | ƒ p |  i i | ƒ qßqßWx* |  i ƒ  D] } |  i | t i d ƒ qWd |  _ d |  _ nÎ |  i pC x* |  i ƒ  D] } |  i | t i d ƒ qgWd |  _ d |  _ n x5 |  i D]* } |  i | ƒ p |  i i | ƒ q§q§Wx3 |  i ƒ  D]% } |  i | t i | |  i j ƒ qâWd |  _ d |  _ |  ` |  ` |  ` n t |  d ƒ o^ |  i } xH | D]@ } |  i | ƒ o |  i | t i d ƒ qS|  i	 i | ƒ qSW|  ` n | d d t i ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ t |  d ƒ oH |  i o$ t i o d |  _ q<d |  _ n
 d |  _ t |  d ƒ n t |  d ƒ p t |  d t i ƒ n t |  d ƒ p t |  d t i  ƒ n t |  d ƒ oM |  i! o |  i o d |  _ qçn |  i o d |  _ n t |  d ƒ n( |  i" d j o |  i o d |  _ n t# |  i$ ƒ t% j o1 h  } x |  i$ D] } d | | <qEW| |  _$ n t# |  i& ƒ t% j o1 h  }	 x |  i& D] }
 d |	 |
 <qŒW|	 |  _& n t |  d ƒ p t |  d t i' ƒ n x™ |  i$ i( ƒ  D]ˆ } | i) ƒ  | j o* t* i+ | ƒ |  i$ | i) ƒ  <|  i$ | =qät# |  i$ | ƒ t, j o | |  i$ | i) ƒ  j o qäd |  i$ | <qäWx™ |  i& i( ƒ  D]ˆ } | i) ƒ  | j o* t* i+ | ƒ |  i& | i) ƒ  <|  i& | =q€t# |  i& | ƒ t, j o | |  i& | i) ƒ  j o q€d |  i& | <q€Wd  S(!   s‹   Transform old variable values into new ones, deleting old ones.
    stored_state is last snapshot from file, as opposed to from InitVars().c         S   s„   t  | |  ƒ o> | i | ƒ p t | | t | |  ƒ ƒ n t | |  ƒ n t  | | ƒ o! | t j	 o t | | | ƒ n d S(   s&  Use specified old value if new value is not in stored state.

        If the old attr does not exist, and no newdefault is specified, the
        new attr is *not* created - so either specify a default or be positive
        that the old attr exists - or don't depend on the new attr.

        N(   R   t   has_keyt   setattrt   getattrR   t	   uniqueval(   t   oldnamet   newnamet
   newdefaultR   t   state(    (    s$   /usr/lib/mailman/Mailman/versions.pyt   PreferStoredP   s    	t   dont_respond_to_post_requestst   respond_to_post_requestst   default_member_moderationt   accept_these_nonmemberst   hold_these_nonmemberst   reject_these_nonmemberst   discard_these_nonmemberst   forward_auto_discardst   generic_nonmember_actiont	   moderatedi   i    t   forbidden_posterst   reminders_to_adminst   umbrella_listt   auto_subscribet   open_subscribet   closedt   private_rostert!   mimimum_post_count_before_removalt'   mimimum_post_count_before_bounce_actiont   bad_posterst   automatically_removeR   i   t   administriviat   admin_member_chunksizet   posters_includes_membersi
   t   admin_notify_mchangesN(-   R"   R   R!   R)   R(   R   t!   DEFAULT_DEFAULT_MEMBER_MODERATIONR*   R+   R,   R-   R.   t   DEFAULT_FORWARD_AUTO_DISCARDSR/   t    DEFAULT_GENERIC_NONMEMBER_ACTIONR0   R1   t   posterst   isMembert   appendt
   getMemberst   setMemberOptiont   Moderatet   member_posting_onlyR2   t   DEFAULT_UMBRELLA_LISTR6   t   ALLOW_OPEN_SUBSCRIBEt   subscribe_policyR   R    t   DEFAULT_ADMINISTRIVIAt   DEFAULT_ADMIN_MEMBER_CHUNKSIZER?   t   data_versiont   typet   membersR    t   digest_memberst   DEFAULT_ADMIN_NOTIFY_MCHANGESt   keyst   lowerR   t   LCDomainR   (   R   R   R'   t   oldvalt   addrt   membert
   forbiddensRR   t   mt   dmemberst   dmt   k(    (    s$   /usr/lib/mailman/Mailman/versions.pyR   L   s   
9

  	

  	
 	
  		
	 
	


		



 
 	 4 c         C   sm  |  d „ } | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d d ƒ | d	 d ƒ | d
 d ƒ | d h  ƒ | d h  ƒ | d d ƒ | d t  i ƒ | d g  ƒ | d t  i ƒ | d d ƒ | d dC ƒ | d g  ƒ | d g  ƒ | d d ƒ | d d ƒ | d h  ƒ | d h  ƒ | d d ƒ | d t  i ƒ | d t  i ƒ | d t  i ƒ | d d  ƒ | d! d  ƒ | d" t  i ƒ | d# t  i ƒ | d$ t  i	 ƒ | d% t  i
 ƒ | d& t  i ƒ | d' t  i ƒ | d( t  i ƒ | d) g  ƒ | d* t  i ƒ | d+ t  i ƒ | d, t  i ƒ | d- t  i ƒ | d. t  i ƒ | d/ h  ƒ | d0 d ƒ | d1 d ƒ | d2 t  i ƒ | d3 d ƒ | d4 h  ƒ | d5 d  ƒ t i |  i ƒ d6 j o
 d } n d7 } | d8 | ƒ | d9 d ƒ | d: g  ƒ | d; d ƒ | d< t  i ƒ | d= g  ƒ | d> d ƒ | d? d ƒ | d@ t  i ƒ | dA t  i ƒ | dB t  i ƒ dC S(D   s9   Add defaults for these new variables if they don't exist.c         S   s(   t  | |  ƒ p t | |  | ƒ n d  S(   N(   R   R    (   t   attrt   initvalR   (    (    s$   /usr/lib/mailman/Mailman/versions.pyt   add_only_if_missingA  s    t   autorespond_postingsi    t   autorespond_admint   autorespond_requestst   autoresponse_postings_textt    t   autoresponse_admin_textt   autoresponse_request_textt   autoresponse_graceperiodiZ   t   postings_responsest   admin_responsest   reply_goes_to_listt   preferred_languaget   available_languagest   digest_volume_frequencyt   digest_last_sent_att   mod_passwordt	   moderatort   topicst   topics_enabledt   topics_bodylines_limiti   t   one_last_digestt	   usernamest   personalizet   first_strip_reply_tot   unsubscribe_policyt   send_goodbye_msgt   include_rfc2369_headersi   t   include_list_post_headert   bounce_score_thresholdt   bounce_info_stale_aftert    bounce_you_are_disabled_warningst)   bounce_you_are_disabled_warnings_intervalt&   bounce_unrecognized_goes_to_list_ownert   bounce_notify_owner_on_disablet   bounce_notify_owner_on_removalt   ban_listt   filter_mime_typest   pass_mime_typest   filter_contentt   convert_html_to_plaintextt   filter_actiont   delivery_statust   member_moderation_actiont   member_moderation_noticet   new_member_optionst	   emergencyt   hold_and_cmd_autoresponsest   news_prefix_subject_toos   us-asciii   t   encode_ascii_prefixest   news_moderationt   header_filter_rulest   scrub_nondigestt   filter_filename_extensionst   pass_filename_extensionst   max_days_to_holdt   nonmember_rejection_noticet   collapse_alternativest   regular_exclude_listst   regular_include_listsN(   R   t   DEFAULT_SERVER_LANGUAGEt   DEFAULT_DIGEST_VOLUME_FREQUENCYt   Nonet   DEFAULT_FIRST_STRIP_REPLY_TOt   DEFAULT_UNSUBSCRIBE_POLICYt   DEFAULT_SEND_GOODBYE_MSGt   DEFAULT_BOUNCE_SCORE_THRESHOLDt   DEFAULT_BOUNCE_INFO_STALE_AFTERt(   DEFAULT_BOUNCE_YOU_ARE_DISABLED_WARNINGSt1   DEFAULT_BOUNCE_YOU_ARE_DISABLED_WARNINGS_INTERVALt.   DEFAULT_BOUNCE_UNRECOGNIZED_GOES_TO_LIST_OWNERt&   DEFAULT_BOUNCE_NOTIFY_OWNER_ON_DISABLEt&   DEFAULT_BOUNCE_NOTIFY_OWNER_ON_REMOVALt   DEFAULT_FILTER_MIME_TYPESt   DEFAULT_PASS_MIME_TYPESt   DEFAULT_FILTER_CONTENTt!   DEFAULT_CONVERT_HTML_TO_PLAINTEXTt   DEFAULT_FILTER_ACTIONt   DEFAULT_NEW_MEMBER_OPTIONSR   t
   GetCharSetRn   t"   DEFAULT_FILTER_FILENAME_EXTENSIONSt   DEFAULT_COLLAPSE_ALTERNATIVESt   DEFAULT_REGULAR_EXCLUDE_LISTSt   DEFAULT_REGULAR_INCLUDE_LISTS(   R   Rb   t   encode(    (    s$   /usr/lib/mailman/Mailman/versions.pyR
   ?  s¤    















c         C   s–   h  } x- |  i  i ƒ  D] \ } } | | | i ƒ  <q W| |  _  xP |  i i ƒ  D]? } |  i | ƒ p t |  i | ƒ t ƒ o |  i | =qO qO Wd S(   s(   Transform sense of changed user options.N(	   t	   passwordst   itemsRV   t   bounce_infoRU   RE   t
   isinstancet   getBounceInfoR   (   R   R·   R_   t   vR\   (    (    s$   /usr/lib/mailman/Mailman/versions.pyR	   ¤  s     	  c         C   s3  t  |  d d ƒ d j o d Sh  } xu |  i i ƒ  D]d \ } } | d j o q4 n | i ƒ  } d } | i | ƒ o | | } n | | O} | | | <q4 W| |  _ x~ |  i i ƒ  D]m \ } } |  i | ƒ p |  i | =qµ n |  i | t i	 ƒ o* |  i
 | t ƒ |  i | t i	 d ƒ qµ qµ Wd |  _ d S(   s   Fix up the user options.t   useropts_versioni    Ni   (   R!   t   user_optionsR¸   R    RV   R   RE   t   getMemberOptionR   t   DisableDeliveryt   setDeliveryStatusR   RH   R½   (   R   t   optionsR_   R¼   t   lcusert   flags(    (    s$   /usr/lib/mailman/Mailman/versions.pyR   µ  s.     
	 
c         C   s  t  |  d h  ƒ } | p d Sxï | i ƒ  D]á \ } } | d j o[ xM | D]E } | d \ } } | d } t i | t i ƒ } |  i | | ƒ qK W| | =q+ | d j oG x9 | D]1 \ }	 }	 }
 } } |  i | d | |
 t i ƒ q³ W| | =q+ t	 d d	 | |  i
 ƒ  ƒ q+ Wd S(
   s?   With version 1.2, we use a new pending request database schema.t   requestsNt   posti   i   t
   add_memberRg   t   errorsD   VERY BAD NEWS.  Unknown pending request type `%s' found for list: %s(   R!   R¸   t   emailt   message_from_stringR   t   HoldMessaget   HoldSubscriptionR   Rž   R   t   internal_name(   R   t   rR_   R¼   t   pt   authort   textt   reasont   msgt   ignt   digestRY   t   password(    (    s$   /usr/lib/mailman/Mailman/versions.pyR   Ù  s,      

 (   t   __doc__RÉ   t   typesR    R   t   MailmanR   R   R   t   Mailman.BouncerR   t   Mailman.MemberAdaptorR   t   Mailman.Logging.SyslogR   R   R   R"   R   R
   R	   R   R   (    (    (    s$   /usr/lib/mailman/Mailman/versions.pyt   <module>!   s    			ó	e		$
