Edgewall Software

Changes between Version 2 and Version 3 of TracDev/Proposals/AdvancedNotification/INotificationFormatter


Ignore:
Timestamp:
Oct 12, 2013, 12:29:01 AM (11 years ago)
Author:
Peter Suter
Comment:

Raise question of how to get at all supported styles.

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/Proposals/AdvancedNotification/INotificationFormatter

    v2 v3  
    3939    def styles(self, transport, realm):
    4040        if transport == 'sms' and realm == 'ticket':
    41             yield 'text/plain and short'
     41            yield 'text/plain'
    4242
    4343    def format(self, transport, style, event):
     
    6464   * DONE Dropped the `alternative_style_for()` method. (The distributor can select fallbacks without this.)
    6565   * DONE Dropped the `realm` parameter to the `format()` method. (Use `event.realm` instead.)
     66
     67== Open questions
     68
     69=== Enumerate all styles?
     70Maybe `styles()` should be changed to enumerate the supported style / transport / realm combinations as tuples:
     71{{{#!python
     72    def styles(self):
     73        yield ('text/plain', 'sms', 'ticket')
     74}}}
     75
     76Advantage: This would give access to the list of all supported styles, without guessing the supported realms. For example a preferences panel could then create a ''preferred style'' selection UI, listing all supported styles.
     77
     78Disadvantage: Formatters could not implement catch-all fallbacks that e.g. claim to support all transports. But all current Announcer formatters do just this.
     79
     80Possible solutions:
     81* ''Do not allow'' formatters to support all transports. Is that actually even feasible? The formatter interface even states that it must be explicitly designed to work with a specific distributor.
     82* ''Require'' all formatters to support all transports. Remove the transports parameter. This would prevent using different formatters for different transports. (At least the return type of `format()` could then probably be defined to some standardized type.)
     83* ''Allow'' formatters to return `None` or `'*'` to support all transports.
     84* Define the interface with ''two methods''. One method with parameters as before; another method without parameters must list all supported styles for any transport or realm.
     85* Define the interface with one method, with ''optional parameters''. If the parameters are `None` the method must list all supported styles for any transport or realm.
     86
     87Similary, could some formatters want to support all realms?
     88
     89The chosen solution should be simple and easy to implement correctly by plugin authors.