| | 46 | class TimeLogSubKeyLookupError(LookupError): |
| | 47 | """A sub-key could not be found for a given id""" |
| | 48 | |
| | 49 | |
| | 50 | class ITimeLogSubKeySource(Interface): |
| | 51 | """A source of sub-keys for a key position |
| | 52 | |
| | 53 | For any given key position only one source can be used, but a source can |
| | 54 | be re-used for multiple key positions. |
| | 55 | |
| | 56 | """ |
| | 57 | def getSubKey(id): |
| | 58 | """Return the `ITimeLogSubKey` with the given id |
| | 59 | |
| | 60 | A ``TimeLogSubKeyLookupError`` is raised when no sub-key with the given |
| | 61 | id exists. |
| | 62 | |
| | 63 | """ |
| | 64 | def listSubKeys(): |
| | 65 | """Return an iterable of all sub-keys""" |
| | 66 | |
| | 67 | |
| | 68 | class ITimeLogKeySource(Interface): |
| | 69 | """A source of ITimeLogSubKeySources""" |
| | 70 | keyLength = Int( |
| | 71 | title=u'Key Length', |
| | 72 | description=u'''Number of sub-key sources provided.''', |
| | 73 | required=True, |
| | 74 | readonly=True) |
| | 75 | |
| | 76 | def getSubKeySource(position): |
| | 77 | """Return an `ITimeLogSubKeySource` for a given key position |
| | 78 | |
| | 79 | Raises an ``IndexError`` when no source exists at that position |
| | 80 | |
| | 81 | """ |
| | 82 | |
| | 83 | |