;ς
’)?Bc           @   s£   d  Z  d k l Z l Z d k l Z d k l Z d k l Z d k l	 Z	 d k
 l Z d   Z d   Z g  Z d	   Z d
   Z d   Z d   Z d   Z d S(   sS  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.

(   s   ListTypes
   StringType(   s   mm_cfg(   s   Utils(   s   Message(   s   UNKNOWN(   s   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(   s
   ZapOldVarss   ls   UpdateOldUserss   NewVarss   UpdateOldVarss   stored_states   CanonicalizeUserOptionss   NewRequestsDatabase(   s   ls   stored_state(    (    s    /var/mailman/Mailman/versions.pys   Update.   s     



c      
   C   sT   xM d d d d d d d d d	 d
 f
 D]' } t |  |  o t |  |  q% q% Wd  S(   Ns
   num_spawnss   filter_progs   clobber_dates   public_archive_file_dirs   private_archive_file_dirs   archive_directorys   minimum_removal_dates'   minimum_post_count_before_bounce_actions   automatic_bounce_actions   max_posts_between_bounces(   s   names   hasattrs   mlists   delattr(   s   mlists   name(    (    s    /var/mailman/Mailman/versions.pys
   ZapOldVars9   s    % 	c         C   s  t  |  | d  }	 t |  d  o8 t |  d  } t |  d  o | |  _ n |  ` n t |  d  o t	 i
 |  _ n t |  d  o g  |  _ n t |  d  o g  |  _ n t |  d  o g  |  _ n t |  d  o g  |  _ n t |  d	  o t	 i |  _ n t |  d
  o t	 i |  _ n t |  d  oϊ|  i o x6 |  i D]+ } |  i |  o |  i i |  qYqYWx3 |  i   D]% } |  i | t	 i | |  i j  qWd |  _ d |  _ nV|  i o| x6 |  i D]+ } |  i |  o |  i i |  qθqθWx* |  i   D] } |  i | t	 i d  q$Wd |  _ d |  _ nΠ |  i oC x* |  i   D] } |  i | t	 i d  qrWd |  _ d |  _ n x6 |  i D]+ } |  i |  o |  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  q_|  i i |  q_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 |  _# qHd |  _# n
 d |  _# t$ |  d  n t |  d  o t% |  d t	 i&  n t |  d  o 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 | | <qSW| |  _+ n t* |  i.  t, j o1 h  } x |  i. D] } d | | <qW| |  _. n t |  d  o t% |  d t	 i1  n x |  i+ i2   D] }
 |
 i4   |
 j o* t5 i6 |
  |  i+ |
 i4   <|  i+ |
 =qσt* |  i+ |
  t7 j o |
 |  i+ |
 i4   j o qσd |  i+ |
 <qσWx |  i. i2   D] }
 |
 i4   |
 j o* t5 i6 |
  |  i. |
 i4   <|  i. |
 =qt* |  i. |
  t7 j o |
 |  i. |
 i4   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         C   s   t  | |   o? | i |  o 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(   s   hasattrs   ls   oldnames   states   has_keys   newnames   setattrs   getattrs   delattrs
   newdefaults	   uniqueval(   s   oldnames   newnames
   newdefaults   ls   state(    (    s    /var/mailman/Mailman/versions.pys   PreferStoredM   s     s   dont_respond_to_post_requestss   respond_to_post_requestss   default_member_moderations   accept_these_nonmemberss   hold_these_nonmemberss   reject_these_nonmemberss   discard_these_nonmemberss   forward_auto_discardss   generic_nonmember_actions	   moderatedi   i    s   forbidden_posterss   reminders_to_adminss   umbrella_lists   auto_subscribes   open_subscribes   closeds   private_rosters!   mimimum_post_count_before_removals'   mimimum_post_count_before_bounce_actions   bad_posterss   automatically_removes   automatic_bounce_actioni   s   administrivias   admin_member_chunksizes   posters_includes_membersi
   s   admin_notify_mchangesN(8   s	   uniquevals   ls   stored_states   PreferStoreds   hasattrs   getattrs   oldvals   respond_to_post_requestss   dont_respond_to_post_requestss   mm_cfgs!   DEFAULT_DEFAULT_MEMBER_MODERATIONs   default_member_moderations   accept_these_nonmemberss   hold_these_nonmemberss   reject_these_nonmemberss   discard_these_nonmemberss   DEFAULT_FORWARD_AUTO_DISCARDSs   forward_auto_discardss    DEFAULT_GENERIC_NONMEMBER_ACTIONs   generic_nonmember_actions	   moderateds   posterss   addrs   isMembers   appends
   getMemberss   members   setMemberOptions   Moderates   member_posting_onlys   forbidden_posterss
   forbiddenss   DEFAULT_UMBRELLA_LISTs   open_subscribes   ALLOW_OPEN_SUBSCRIBEs   subscribe_policys   delattrs   setattrs   DEFAULT_ADMINISTRIVIAs   DEFAULT_ADMIN_MEMBER_CHUNKSIZEs   posters_includes_memberss   data_versions   types   memberss   ListTypes   ms   digest_memberss   dmemberss   dms   DEFAULT_ADMIN_NOTIFY_MCHANGESs   keyss   ks   lowers   Utilss   LCDomains
   StringType(   s   ls   stored_states   members   addrs   oldvals
   forbiddenss   dms   dmemberss   memberss   PreferStoreds   ks   m(    (    s    /var/mailman/Mailman/versions.pys   UpdateOldVarsI   s    
9

  	

  	 	
  		
	 
	


		



 
 	 4 4c         C   sω  |  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 t  | 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; S(<   s9   Add defaults for these new variables if they don't exist.c         C   s)   t  | |   o t | |  |  n d  S(   N(   s   hasattrs   ls   attrs   setattrs   initval(   s   attrs   initvals   l(    (    s    /var/mailman/Mailman/versions.pys   add_only_if_missing>  s    s   autorespond_postingsi    s   autorespond_admins   autorespond_requestss   autoresponse_postings_texts    s   autoresponse_admin_texts   autoresponse_request_texts   autoresponse_graceperiodiZ   s   postings_responsess   admin_responsess   reply_goes_to_lists   preferred_languages   available_languagess   digest_volume_frequencys   digest_last_sent_ats   mod_passwords	   moderators   topicss   topics_enableds   topics_bodylines_limiti   s   one_last_digests	   usernamess   personalizes   first_strip_reply_tos   unsubscribe_policys   send_goodbye_msgs   include_rfc2369_headersi   s   include_list_post_headers   bounce_score_thresholds   bounce_info_stale_afters    bounce_you_are_disabled_warningss)   bounce_you_are_disabled_warnings_intervals&   bounce_unrecognized_goes_to_list_owners   bounce_notify_owner_on_disables   bounce_notify_owner_on_removals   ban_lists   filter_mime_typess   pass_mime_typess   filter_contents   convert_html_to_plaintexts   filter_actions   delivery_statuss   member_moderation_actions   member_moderation_notices   new_member_optionss	   emergencys   hold_and_cmd_autoresponsess   news_prefix_subject_toos   us-asciii   s   encode_ascii_prefixess   news_moderations   header_filter_rulesN(   s   ls   add_only_if_missings   mm_cfgs   DEFAULT_SERVER_LANGUAGEs   DEFAULT_DIGEST_VOLUME_FREQUENCYs   Nones   DEFAULT_FIRST_STRIP_REPLY_TOs   DEFAULT_UNSUBSCRIBE_POLICYs   DEFAULT_SEND_GOODBYE_MSGs   DEFAULT_BOUNCE_SCORE_THRESHOLDs   DEFAULT_BOUNCE_INFO_STALE_AFTERs(   DEFAULT_BOUNCE_YOU_ARE_DISABLED_WARNINGSs1   DEFAULT_BOUNCE_YOU_ARE_DISABLED_WARNINGS_INTERVALs.   DEFAULT_BOUNCE_UNRECOGNIZED_GOES_TO_LIST_OWNERs&   DEFAULT_BOUNCE_NOTIFY_OWNER_ON_DISABLEs&   DEFAULT_BOUNCE_NOTIFY_OWNER_ON_REMOVALs   DEFAULT_FILTER_MIME_TYPESs   DEFAULT_PASS_MIME_TYPESs   DEFAULT_FILTER_CONTENTs!   DEFAULT_CONVERT_HTML_TO_PLAINTEXTs   DEFAULT_FILTER_ACTIONs   DEFAULT_NEW_MEMBER_OPTIONSs   Utilss
   GetCharSets   preferred_languages   encode(   s   ls   encodes   add_only_if_missing(    (    s    /var/mailman/Mailman/versions.pys   NewVars<  s     












c         C   s£   h  } x- |  i  i   D] \ } } | | | i   <q W| |  _  d k l } xP |  i i	   D]? } |  i |  p t |  i |  |  o |  i | =q\ q\ Wd S(   s(   Transform sense of changed user options.(   s   _BounceInfoN(   s	   passwordss   mlists   itemss   ks   vs   lowers   Mailman.Bouncers   _BounceInfos   bounce_infos   keyss   ms   isMembers
   isinstances   getBounceInfo(   s   mlists	   passwordss   ks   ms   vs   _BounceInfo(    (    s    /var/mailman/Mailman/versions.pys   UpdateOldUsers  s      	  c         C   s7  t  |  d d  d j o d Sn h  } xu |  i i   D]d \ } } | t j o q7 n | i   } d } | i |  o | | } n | | O} | | | <q7 W| |  _ x |  i i   D]n \ } } |  i |  o |  i | =qΈ n |  i | t i  o* |  i | t  |  i | t i d  qΈ qΈ Wd |  _ d S(   s   Fix up the user options.s   useropts_versioni    Ni   (   s   getattrs   ls   optionss   user_optionss   itemss   ks   vs   Nones   lowers   lcusers   flagss   has_keys   isMembers   getMemberOptions   mm_cfgs   DisableDeliverys   setDeliveryStatuss   UNKNOWNs   setMemberOptions   useropts_version(   s   ls   lcusers   ks   flagss   vs   options(    (    s    /var/mailman/Mailman/versions.pys   CanonicalizeUserOptions’  s0      
	 
c         C   s  t  |  d h   } | o d Sn xι | i   D]Ϋ \ } } | d j oU xG | D]? } | d \ } } | d } t
 i |  } |  i | |  qO 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.s   requestsNs   posti   i   s
   add_members    s   errorsD   VERY BAD NEWS.  Unknown pending request type `%s' found for list: %s(   s   getattrs   ls   rs   itemss   ks   vs   ps   authors   texts   reasons   Messages   OutgoingMessages   msgs   HoldMessages   igns   digests   addrs   passwords   HoldSubscriptions   mm_cfgs   DEFAULT_SERVER_LANGUAGEs   syslogs   internal_name(   s   ls   addrs   authors   texts   ks   ps   rs   vs   reasons   igns   passwords   digests   msg(    (    s    /var/mailman/Mailman/versions.pys   NewRequestsDatabaseΖ  s.       

 N(   s   __doc__s   typess   ListTypes
   StringTypes   Mailmans   mm_cfgs   Utilss   Messages   Mailman.MemberAdaptors   UNKNOWNs   Mailman.Logging.Syslogs   syslogs   Updates
   ZapOldVarss	   uniquevals   UpdateOldVarss   NewVarss   UpdateOldUserss   CanonicalizeUserOptionss   NewRequestsDatabase(   s
   ZapOldVarss
   StringTypes	   uniquevals   UpdateOldVarss   UpdateOldUserss   UNKNOWNs   Utilss   NewRequestsDatabases   Updates   CanonicalizeUserOptionss   NewVarss   syslogs   mm_cfgs   ListTypes   Message(    (    s    /var/mailman/Mailman/versions.pys   ?!   s   			σ	T		$