[Mailman-Users] hide lists from listinfo page only (leaveonadmin page)

Xiaoyan Ma xma at uclink.berkeley.edu
Tue Oct 11 08:57:52 CEST 2005


> By default, Python will only access modules in the Python libraries and
> the directory that contains the current module. Modules in the bin/
> directory for example get around this by importing 'paths' which is
> the bin/paths.py file which sets some additional directories in the
> search paths.
> 
> The easiest way to make this work for testing purposes is just to store
> your test file in the $prefix directory, i.e. the directory that
> contains the Mailman/, bin/, etc. directories.
> A key thing in Python code is indentation because that's how Python
> determines block structure. It is critical that things be indented
> consistently and that either tabs or spaces but not a mixture be used
> for indentation. The above snippet, properly indented looks like
> 
> for name in listnames:
>      if name in notshowns:
>         continue
>      mlist = MailList.MailList(name, lock=0)
>         if mlist.advertised:
> 
> It is critical that "if name in notshowns:" is indented exactly the
> same amount as "mlist = MailList.MailList(name, lock=0)" and that
> other indentation be preserved exactly as in the original.
> 

Thank you so much for your help. I got it to work!

I found out that I made two errors by testing the script from $PREFIX directory as you suggested. 
One was indentation. The other was the failure to clean up all the newlines when I extracted 
listnames that I wanted to hide from a file (one listname per line).


Here is what I have now:
myfile = '/var/mailman/Mailman/Cgi/notshown'
     noshowns = string.split(open(myfile).read())
     noshowns.sort()


     for name in listnames:
         if name in noshowns:
            continue
         mlist = MailList.MailList(name, lock=0)
         if mlist.advertised:
             if mm_cfg.VIRTUAL_HOST_OVERVIEW and \
                    mlist.web_page_url.find(hostname) == -1:
                 # List is for different identity of this host - skip it.
                 continue
             else:
                 advertised.append((mlist.GetScriptURL('listinfo'),
                                    mlist.real_name,
                                    mlist.description))

Since I need to store a few hundreds listnames in the file, I wonder if it might be better
to use regular expressions.  Five to six regular expressions should be sufficient to match all the
list names I want to hide.

Another option (if it is doable) is to use Mailman's supported advertise feature to hide these
  lists from both listinfo and admin page. I will subsequently bring up a third page, either a
"sub-admin" page showing only those hidden course lists, or a "supper admin" page displaying
all lists.  The goal is that future upgrades won't entail re-customizing the previously customized 
package files.  But I am afraid this may turn out to be so complicated as to involve security 
wrapper and other matters.

I would be very grateful to have your feed back.

Thanks.
Xiaoyan



More information about the Mailman-Users mailing list