[Mailman-Developers] Adding a new list attribute
Danci Emanuel
danci_emanuel at yahoo.com
Sun Jul 1 23:54:23 CEST 2012
Hi again!
As I said in an earlier post, I am a GSoC student, working for the Systers organization, on integrating the
dynamic sublists feature ( http://systers.org/systers-dev/doku.php/good_to_know?s%5B%5D=postgresql )
with Mailman 3.0, and I am facing a small problem.
What I wanna do is to adapt the UI and the back-end so they contain the options
needed in order to enable/disable this feature for a list (at creation or after it has already
been created).
I want to get this right, so it would work as good as possible, so this is what I have done
and the error I get:
Firstly, in the class "ListNew" from "forms.py" I added a new ChoiceField, named
"dlists_enabled" (the naming and the text from the labels are temporary until I get
the feature to completely work)
dlists_enabled = forms.ChoiceField(
widget = forms.RadioSelect(),
label = _("Enable dlists for this list?"),
error_messages = {
'required': _("Please choose an option."),
},
required = True,
choices = (
(True, _("Enable dlists for this list")),
(False, _("Do not enable dlists for this list"))
))
This is working properly because if I print the result of "form.cleaned_data['dlists_enabled']" from
"views.py", in a file, it correctly prints the option chosen by the list owner (True or False).
I also added to "views.py" in the "list_new" function the following line (In the try block where
list_setting are saved):
list_settings["dlists_enabled"] = form.cleaned_data['dlists_enabled']
Secondly, I tried to modify the list attributes by adding the following:
dlists_enabled = Attribute("""Is the Dynamic sublist feature enabled?""") - "IMailingList" interface (/interfaces/mailinglist.py)
dlists_enabled = Bool() - "MailingList" class (/model/mailinglist.py)
dlists_enabled = GetterSetter(as_boolean) - to the ATTRIBUTES dict from /rest/configuration.py
mlist.dlists_enabled = True - in the "apply" method from "DefaultStyle" class (/styles/default.py)
Obviously I did something wrong, or I did not add all the necessary changes because when I try to create
a new lists that has the dlists feature enabled, I get the HTTP Error 400:
HTTP Error 400: Unknown attribute: dlists_enabled
Thanks in advance for your feedback!
Emanuel
More information about the Mailman-Developers
mailing list