Skip to content

WIP: Phase1

username-removed-390361 requested to merge _Harshit_/mailman:phase1 into master

GSOC Project: Preset List Settings Template.
This is the first merge request in a series of four merge requests(two in mailman core, one in mailman client and one in postorius).

Goals achieved:
1: Allow for storing of styles in database:
For serving this purpose, I have introduced two new models:
1: Stylet
2: Style
Stylets are a partial set of styleable attributes that can be used to compose styles which are a stack of stylets such that stylet at the top overrides the values of the common attributes.
2: Allow for the automatic updation of the settings of the mailing list as soon as the style being used by it is updated:
I have used two of the SqlAlchemy's session level events for this purpose 'after_flush' and 'after_flush_postexec'. Both of the events are fired as soon as a flush occurs. In the 'after_flush', we collect all the stylet/style objects in which there are any net changes. Since this event doesn't allow us to emit further SQL until the flush has been performed, hence I have used after_flush_postexec which is triggered after the flush the has been executed. In this event we update all the mailing list which use the updated stylet/style.
3: Change the style used by a mailing list after its creation:
This merge request allows for the changing of the style of the mailing list after its creation. The mailing list whose style is changed will start to follow the new style such that any changes made to any style(or any stylet of which this style is composed) will be reflected in the mailing list. However, one important thing to be noted is that there is only a loose coupling between a mailing list and the style it uses in the sense that if a mailing list was using a style which for example defined a value of True for the 'advertised' attribute and later on it switches to another style which defines no value for the 'advertised' attribute then the mailing list will continue to have a value of True for the 'advertised' attribute until the new style defines a value for this attribute.
4: Make a stylet/style immutable:
This merge request allows for making a stylet/style immutable. A style once set immutable can't be modified. For this purpose I have overridden the 'setattr' method of the style and stylet model and if a style has been set immutable we raise a StyleUpdateError.
5: Porting the default stylets/styles:
I have ported the default stylets and styles. The stylets/styles are added to the database to the automatically during startup if the stylet table(and hence the style table) is empty.

Things yet to be done:
1: Remove _url fields: (Done) After the merging of the templates branch, _url fields are no longer styleable and hence to be removed.
2: Documentation:
The stylet/style update system and the loose coupling between the styles and the mailing list is too complex and will need extensive documentation.

Merge request reports