diff options
| author | Barry Warsaw | 2012-12-28 16:35:08 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2012-12-28 16:35:08 -0500 |
| commit | 582d6e486f9693a2ce082071b747eec468df19b6 (patch) | |
| tree | c25dcc945f161c6d44154c20de72793702be313e /src/mailman/interfaces | |
| parent | 2b663ac20e7898167cf242d3628f8cf0feeab12f (diff) | |
| download | mailman-582d6e486f9693a2ce082071b747eec468df19b6.tar.gz mailman-582d6e486f9693a2ce082071b747eec468df19b6.tar.zst mailman-582d6e486f9693a2ce082071b747eec468df19b6.zip | |
LP: #975692 phase 1
* Rework list style management. No more style priorities or matching.. Now,
you name a style explicitly to apply and that's it.
* create_list() now takes a `style` argument.
* config file now names both a default style to use, and a set of paths to
scan for IStyle instances. (This could be a model for other plugins.)
* added IMailingList.style_name to record the last style applied, but this is
going to be removed in subsequent revisions.
Also:
* Move find_components() and scan_module() from app/finder.py to
utilities/modules.py
* Cleaned up lifecycle.rst for better documentation. Some tests moved to
test_lifecycle.py.
* Remove some unnecessary test tearDown() code.
Diffstat (limited to 'src/mailman/interfaces')
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 3 | ||||
| -rw-r--r-- | src/mailman/interfaces/styles.py | 48 |
2 files changed, 11 insertions, 40 deletions
diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index 8a4436a21..798680782 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -132,6 +132,9 @@ class IMailingList(Interface): """Advertise this mailing list when people ask for an overview of the available mailing lists.""") + style_name = Attribute( + """The name of the last style applied, or None.""") + # Contact addresses posting_address = Attribute( diff --git a/src/mailman/interfaces/styles.py b/src/mailman/interfaces/styles.py index 8dfd52145..4a7b69dcb 100644 --- a/src/mailman/interfaces/styles.py +++ b/src/mailman/interfaces/styles.py @@ -43,9 +43,6 @@ class IStyle(Interface): name = Attribute( """The name of this style. Must be unique.""") - priority = Attribute( - """The priority of this style, as an integer.""") - def apply(mailing_list): """Apply the style to the mailing list. @@ -53,50 +50,28 @@ class IStyle(Interface): :param mailing_list: the mailing list to apply the style to. """ - def match(mailing_list, styles): - """Give this style a chance to match the mailing list. - - If the style's internal matching rules match the `mailing_list`, then - the style may append itself to the `styles` list. This list will be - ordered when returned from `IStyleManager.lookup()`. - - :type mailing_list: `IMailingList`. - :param mailing_list: the mailing list object. - :param styles: ordered list of `IStyles` matched so far. - """ - - class IStyleManager(Interface): - """A manager of styles and style chains.""" + """A manager of styles.""" def get(name): """Return the named style or None. - :type name: Unicode + :type name: string :param name: A style name. :return: the named `IStyle` or None if the style doesn't exist. """ - def lookup(mailing_list): - """Return a list of styles for the given mailing list. - - Use various registered rules to find an `IStyle` for the given mailing - list. The returned styles are ordered by their priority. + styles = Attribute( + 'An iterator over all the styles known by this manager.') - Style matches can be registered and reordered by plugins. + def populate(): + """Populate the styles from the configuration files. - :type mailing_list: `IMailingList`. - :param mailing_list: The mailing list object to find a style for. - :return: ordered list of `IStyles`. Zero is the lowest priority. + This clears the current set of styles and resets them from those + defined in the configuration files. """ - styles = Attribute( - """An iterator over all the styles known by this manager. - - Styles are ordered by their priority, which may be changed. - """) - def register(style): """Register a style with this manager. @@ -111,10 +86,3 @@ class IStyleManager(Interface): :param style: an IStyle. :raises KeyError: If the style's name is not currently registered. """ - - def populate(): - """Populate the styles from the configuration files. - - This clears the current set of styles and resets them from those - defined in the configuration files. - """ |
