Changeset 29
- Timestamp:
- 08/14/05 12:43:59 (6 years ago)
- Location:
- trunk/src/chronolog
- Files:
-
- 3 modified
-
interfaces.py (modified) (1 diff)
-
keys/simpledomain.py (modified) (4 diffs)
-
keys/tests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/chronolog/interfaces.py
r21 r29 66 66 readonly=True) 67 67 68 title = TextLine( 69 title=_(u'Title'), 70 description=_(u'The domain title for UI display'), 71 required=False) 72 73 description = Text( 74 title=_(u'Description'), 75 description=_(u'A detailed description of the domain.'), 76 required=False) 77 68 78 69 79 class ITimeLogEntry(Interface): -
trunk/src/chronolog/keys/simpledomain.py
r23 r29 17 17 from zope.interface import implements 18 18 19 from zope.app.annotation.interfaces import IAttributeAnnotatable 19 20 from zope.app.container.interfaces import IContainer 20 21 from zope.app.container.btree import BTreeContainer … … 22 23 from zope.app.component.interfaces.registration import IRegisterable 23 24 from zope.app.component.interfaces.registration import IRegistered 25 from zope.app.dublincore.interfaces import IZopeDublinCore 24 26 25 27 from chronolog.interfaces import ITimeLogKeyDomain … … 34 36 35 37 class SimpleKeyDomain(BTreeContainer): 36 """Persistent local utility domain""" 38 """Persistent local utility domain 39 40 title and description are implemented in terms of their Dublin Core 41 counterparts. This ensures that we can implement the interface without 42 then having conflicting UI: 37 43 38 implements(ITimeLogKeyDomain, IContainerTimeLogKeyDomain, IRegisterable) 44 >>> from chronolog.keys.simpledomain import SimpleKeyDomain 45 >>> domain = SimpleKeyDomain() 46 47 Title and description are really Dublin Core fields: 48 49 >>> domain.title = u'Foo title' 50 >>> domain.description = u'Foo description' 51 >>> from zope.app.dublincore.interfaces import IZopeDublinCore 52 >>> IZopeDublinCore(domain).title 53 u'Foo title' 54 >>> IZopeDublinCore(domain).description 55 u'Foo description' 56 57 This, of course, also works the other way around: 58 59 >>> IZopeDublinCore(domain).title = u'Bar title' 60 >>> IZopeDublinCore(domain).description = u'Bar description' 61 >>> domain.title 62 u'Bar title' 63 >>> domain.description 64 u'Bar description' 65 66 The id is defined as the first name under which we where registered. 67 So if a SimpleKeyDomain is registered under the name 'foo', the id 68 attribute should reflect that: 69 70 >>> from chronolog.interfaces import ITimeLogKeyDomain 71 >>> from zope.app import zapi 72 >>> domain = zapi.getUtility(ITimeLogKeyDomain, u'foo') 73 >>> domain.id 74 u'foo' 75 76 Of course, if it was registered nameless, the id should reflect that too: 77 78 >>> domain = zapi.getUtility(ITimeLogKeyDomain) 79 >>> domain.id 80 u'' 81 82 """ 83 84 implements(ITimeLogKeyDomain, IContainerTimeLogKeyDomain, IRegisterable, 85 IAttributeAnnotatable) 39 86 40 87 def getId(self): 41 """Return the id of the domain. 42 43 The name is defined as the first name under which we where registered. 44 So if a SimpleKeyDomain is registered under the name 'foo', the id 45 attribute should reflect that: 46 47 >>> from chronolog.interfaces import ITimeLogKeyDomain 48 >>> from zope.app import zapi 49 >>> domain = zapi.getUtility(ITimeLogKeyDomain, u'foo') 50 >>> domain.id 51 u'foo' 52 53 Of course, if it was registered nameless, the id should reflect that 54 too: 55 56 >>> domain = zapi.getUtility(ITimeLogKeyDomain) 57 >>> domain.id 58 u'' 59 88 """Return the id of the domain 60 89 """ 61 90 registrations = IRegistered(self).registrations() … … 63 92 return '' 64 93 return registrations[0].name 94 id = property(getId) 65 95 66 id = property(getId) 96 def getTitle(self): return IZopeDublinCore(self).title 97 def setTitle(self, title): IZopeDublinCore(self).title = title 98 title = property(getTitle, setTitle) 99 100 def getDesc(self): return IZopeDublinCore(self).description 101 def setDesc(self, desc): IZopeDublinCore(self).description = desc 102 description = property(getDesc, setDesc) 103 -
trunk/src/chronolog/keys/tests.py
r28 r29 21 21 22 22 from zope.interface import implements 23 from zope.app.annotation.interfaces import IAnnotations 24 from zope.app.annotation.interfaces import IAttributeAnnotatable 25 from zope.app.annotation.attribute import AttributeAnnotations 23 26 from zope.app.component.interfaces.registration import IRegistered 27 from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter 28 from zope.app.dublincore.interfaces import IWriteZopeDublinCore 24 29 25 30 … … 47 52 ztapi.provideAdapter(ITimeLogKeyDomain, IRegistered, 48 53 DummyRegisteredAdapter) 54 ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations, 55 AttributeAnnotations) 56 ztapi.provideAdapter(IAttributeAnnotatable, IWriteZopeDublinCore, 57 ZDCAnnotatableAdapter) 49 58 50 59 namelessDomain = SimpleKeyDomain() … … 57 66 58 67 def simpleSetUp(test): 59 from zope.app.annotation.interfaces import IAnnotations60 from zope.app.annotation.interfaces import IAttributeAnnotatable61 from zope.app.annotation.attribute import AttributeAnnotations62 from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter63 from zope.app.dublincore.interfaces import IWriteZopeDublinCore64 65 68 placelesssetup.setUp(test) 66 69 ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
