Changeset 29

Show
Ignore:
Timestamp:
08/14/05 12:43:59 (6 years ago)
Author:
mj
Message:

Change my mind: domains should have a title and desc anyway. The persistant version can use DC just like the simple key class can.

Location:
trunk/src/chronolog
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/chronolog/interfaces.py

    r21 r29  
    6666        readonly=True) 
    6767 
     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 
    6878 
    6979class ITimeLogEntry(Interface): 
  • trunk/src/chronolog/keys/simpledomain.py

    r23 r29  
    1717from zope.interface import implements 
    1818 
     19from zope.app.annotation.interfaces import IAttributeAnnotatable 
    1920from zope.app.container.interfaces import IContainer 
    2021from zope.app.container.btree import BTreeContainer 
     
    2223from zope.app.component.interfaces.registration import IRegisterable 
    2324from zope.app.component.interfaces.registration import IRegistered 
     25from zope.app.dublincore.interfaces import IZopeDublinCore 
    2426 
    2527from chronolog.interfaces import ITimeLogKeyDomain 
     
    3436 
    3537class 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: 
    3743     
    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) 
    3986     
    4087    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 
    6089        """ 
    6190        registrations = IRegistered(self).registrations() 
     
    6392            return '' 
    6493        return registrations[0].name 
     94    id = property(getId) 
    6595 
    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  
    2121 
    2222from zope.interface import implements 
     23from zope.app.annotation.interfaces import IAnnotations 
     24from zope.app.annotation.interfaces import IAttributeAnnotatable 
     25from zope.app.annotation.attribute import AttributeAnnotations 
    2326from zope.app.component.interfaces.registration import IRegistered 
     27from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter 
     28from zope.app.dublincore.interfaces import IWriteZopeDublinCore 
    2429 
    2530 
     
    4752    ztapi.provideAdapter(ITimeLogKeyDomain, IRegistered,  
    4853                         DummyRegisteredAdapter) 
     54    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,  
     55                         AttributeAnnotations) 
     56    ztapi.provideAdapter(IAttributeAnnotatable, IWriteZopeDublinCore,  
     57                         ZDCAnnotatableAdapter) 
    4958     
    5059    namelessDomain = SimpleKeyDomain() 
     
    5766 
    5867def simpleSetUp(test): 
    59     from zope.app.annotation.interfaces import IAnnotations 
    60     from zope.app.annotation.interfaces import IAttributeAnnotatable 
    61     from zope.app.annotation.attribute import AttributeAnnotations 
    62     from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter 
    63     from zope.app.dublincore.interfaces import IWriteZopeDublinCore 
    64  
    6568    placelesssetup.setUp(test) 
    6669    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,