| 46 | | """INameChooser adapter for ILocalTimeLogKeyDomainsCollections""" |
| | 46 | """INameChooser adapter for ILocalTimeLogKeyDomainsCollections |
| | 47 | |
| | 48 | This NameChooser uses the id of the domain objects passed in as the name |
| | 49 | to be used. We'll use a mockup object to demonstrate this with: |
| | 50 | |
| | 51 | >>> class DummyDomain: |
| | 52 | ... def __init__(self, id='foo'): |
| | 53 | ... self.id = id |
| | 54 | ... |
| | 55 | |
| | 56 | It'll refuse any name that is not the id of the domain object |
| | 57 | outright: |
| | 58 | |
| | 59 | >>> from chronolog.keys.domainscollection import DomainNameChooser |
| | 60 | >>> chooser = DomainNameChooser({}) |
| | 61 | >>> chooser.checkName('foo', DummyDomain()) |
| | 62 | True |
| | 63 | >>> chooser.checkName('bar', DummyDomain()) |
| | 64 | Traceback (most recent call last): |
| | 65 | ... |
| | 66 | UserError: Given name and domain id do not match! |
| | 67 | |
| | 68 | As stated, the choosen name will be taken from the domain object itself, |
| | 69 | and the passed in name is ignored: |
| | 70 | |
| | 71 | >>> chooser.chooseName('bar', DummyDomain()) |
| | 72 | 'foo' |
| | 73 | |
| | 74 | """ |