Adding a new list attribute
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
On Jul 01, 2012, at 02:54 PM, Danci Emanuel wrote:
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()
If you want this value to persist, it must also be added to the SQL tables, e.g. sqlite.sql and/or postgres.sql. This will make your schema incompatible with upstream Mailman, and there will be a better way to extend the default schema in the future, but for now, this should be enough to get you going again.
Of course, it's not necessary to store your data in the primary database. Once you've got a REST API for your stuff, you can really map this to any backend storage you want.
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
That error gets thrown on line 233 of configuration.py and it only happens if the attribute name isn't found in ATTRIBUTES. Probably the best way to debug this is to set a break point in get_configuration() and step through it when self._attribute == 'dlist_enabled'.
Cheers, -Barry
participants (2)
-
Barry Warsaw
-
Danci Emanuel