summaryrefslogtreecommitdiff
path: root/Mailman/Cgi
diff options
context:
space:
mode:
authorbwarsaw2007-01-18 06:29:42 +0000
committerbwarsaw2007-01-18 06:29:42 +0000
commit372d4c2fdf072f6bfedca5fc84a2d5bb427418e6 (patch)
tree594db647158d8156f51ea6d05aba093f29ae061e /Mailman/Cgi
parent1e63bc4a3b6d9197e66f57e11f4b6733a3b324dd (diff)
downloadmailman-372d4c2fdf072f6bfedca5fc84a2d5bb427418e6.tar.gz
mailman-372d4c2fdf072f6bfedca5fc84a2d5bb427418e6.tar.zst
mailman-372d4c2fdf072f6bfedca5fc84a2d5bb427418e6.zip
Rework MailList.available_languages so that we don't need to use a PickleType
column in the database for this list of strings. We use SQLAlchemy's many-to-many relationship, however because of this, you cannot simply append new unicodes to .available_languages. You need to wrap the language code in a Language instance and append that instance to the list. In order to handle this, I added a property MailList.language_codes which returns a list of the code strings (not Language instances). Also new are MailList.set_languages() for setting (i.e. overriding) the set of available languages for the list; and add_language() which takes a single language code, wraps it, and appends it. The code does not and should not use .available_languages directory any more. MailList.GetAvailableLanguages() is removed. The 'available_languages' column is removed from the Listdata table. Add a getValue() to Mailman.Gui.Language in order to unwrap the language codes stored in the database's association table. Modify _setValue() to do the wrapping. In dbcontext.py, don't import * from the sqlalchemy package. It contains a 'logging' name which is not the standard Python logging package. I also added essentially a bag of attributes class called Tables which will hold references to all the SA tables that are created. Update the make_table() API to take an instance of Tables. Added a close() method to DBContext. This is needed for the updated unit test suite. Changed bin/import.py so that when available_languages is being set, it calls MailList.set_languages() instead of trying to set that attribute directly. Updated some language idioms while I was at it. More eradication of mm_cfg in favor of the config object and the Defaults module. In testall.py, call initialize() instead of loginit.initialize(). Promote MAX_RESTARTS into a Defaults.py.in variable. This is because the unit tests will knock that value down to something not so annoying should one of the qrunner-required tests traceback. Several other important changes to the unit test suite (which now completely succeeds again!): - Set the uid and gid of the temporary mailman.cfg and tmp*.db files to the Mailman user and group as specified in the config object. - Make sure that all of the tests point to a SQLite database file that was created with the tempfile module. This way we don't pollute our main database with data that is getting created during the unit tests. - In the TestBase.setUp() method, be sure to close the existing dbcontext, clear out the mappers, and then reconnect the dbcontext with the new SQLALCHEMY_ENGINE_URL pointing to the tempfile. However, we don't need to reload the MailList instance any more. - Make all tests work, except for the tests that require crypt. That upgrade path will not be available in this version of Mailman.
Diffstat (limited to 'Mailman/Cgi')
-rw-r--r--Mailman/Cgi/admin.py10
-rw-r--r--Mailman/Cgi/confirm.py4
-rw-r--r--Mailman/Cgi/listinfo.py4
-rw-r--r--Mailman/Cgi/options.py4
4 files changed, 11 insertions, 11 deletions
diff --git a/Mailman/Cgi/admin.py b/Mailman/Cgi/admin.py
index 6977b4592..5cbf1affc 100644
--- a/Mailman/Cgi/admin.py
+++ b/Mailman/Cgi/admin.py
@@ -626,11 +626,11 @@ def get_item_gui_value(mlist, category, kind, varname, params, extra):
return container
elif kind == mm_cfg.Select:
if params:
- values, legend, selected = params
+ values, legend, selected = params
else:
- values = mlist.GetAvailableLanguages()
- legend = map(_, map(Utils.GetLanguageDescr, values))
- selected = values.index(mlist.preferred_language)
+ codes = mlist.language_codes
+ legend = [Utils.GetLanguageDescr(code) for code in codes]
+ selected = codes.index(mlist.preferred_language)
return SelectOptions(varname, values, legend, selected)
elif kind == mm_cfg.Topics:
# A complex and specialized widget type that allows for setting of a
@@ -990,7 +990,7 @@ def membership_options(mlist, subcat, cgidata, doc, form):
cells.append(Center(CheckBox('%s_plain' % addr, value, checked)))
# User's preferred language
langpref = mlist.getMemberLanguage(addr)
- langs = mlist.GetAvailableLanguages()
+ langs = mlist.language_codes
langdescs = [_(Utils.GetLanguageDescr(lang)) for lang in langs]
try:
selected = langs.index(langpref)
diff --git a/Mailman/Cgi/confirm.py b/Mailman/Cgi/confirm.py
index 626a80c02..d2bc3b0aa 100644
--- a/Mailman/Cgi/confirm.py
+++ b/Mailman/Cgi/confirm.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2007 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -285,7 +285,7 @@ def subscription_prompt(mlist, doc, cookie, userdesc):
table.AddRow([Label(_('Receive digests?')),
RadioButtonArray('digests', (_('No'), _('Yes')),
checked=digest, values=(0, 1))])
- langs = mlist.GetAvailableLanguages()
+ langs = mlist.language_codes
values = [_(Utils.GetLanguageDescr(l)) for l in langs]
try:
selected = langs.index(lang)
diff --git a/Mailman/Cgi/listinfo.py b/Mailman/Cgi/listinfo.py
index 37c7f8ea9..b43d10f91 100644
--- a/Mailman/Cgi/listinfo.py
+++ b/Mailman/Cgi/listinfo.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2006 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2007 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -191,7 +191,7 @@ def list_listinfo(mlist, lang):
_('Edit Options')).Format()
# If only one language is enabled for this mailing list, omit the choice
# buttons.
- if len(mlist.GetAvailableLanguages()) == 1:
+ if len(mlist.language_codes) == 1:
displang = ''
else:
displang = mlist.FormatButton('displang-button',
diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py
index 1ce8ee234..f357bcf15 100644
--- a/Mailman/Cgi/options.py
+++ b/Mailman/Cgi/options.py
@@ -540,7 +540,7 @@ address. Upon confirmation, any other mailing list containing the address
newvals.append((flag, newval))
# The user language is handled a little differently
- if userlang not in mlist.GetAvailableLanguages():
+ if userlang not in mlist.language_codes:
newvals.append((SETLANGUAGE, mlist.preferred_language))
else:
newvals.append((SETLANGUAGE, userlang))
@@ -828,7 +828,7 @@ def loginpage(mlist, doc, user, lang):
table.AddRow([Center(Header(2, title))])
table.AddCellInfo(table.GetCurrentRowIndex(), 0,
bgcolor=mm_cfg.WEB_HEADER_COLOR)
- if len(mlist.GetAvailableLanguages()) > 1:
+ if len(mlist.language_codes) > 1:
langform = Form(actionurl)
langform.AddItem(SubmitButton('displang-button',
_('View this page in')))