Changeset 296

Show
Ignore:
Timestamp:
01/29/08 23:26:49 (10 months ago)
Author:
johnbywater
Message:

Added support for temporal persistence of domain object attributes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/dm/application.py

    r97 r296  
    11from dm.ioc import * 
    22from dm.builder import ApplicationBuilder 
     3from dm.testunit import ApplicationBuilder 
    34 
    45class Application(object): 
  • trunk/src/dm/builder.py

    r18 r296  
    1919        features.register('FileSystem',       self.findFileSystem()) 
    2020        features.register('AccessController', self.findAccessController()) 
     21        features.register('Timepoint',        self.findTimepoint()) 
    2122 
    2223    def findSystemDictionary(self): 
     
    6465        return dm.accesscontrol.SystemAccessController() 
    6566 
     67    def findTimepoint(self): 
     68        import dm.timepoint 
     69        return dm.timepoint.Timepoint() 
     70 
  • trunk/src/dm/db.py

    r294 r296  
    4848debug = RequiredFeature('Debug') 
    4949logger = RequiredFeature('Logger') 
     50timepoint = RequiredFeature('Timepoint') 
    5051 
    5152moddebug = False 
     
    144145            if '__dateCreatedAfter__' in kwds: 
    145146                return True 
     147            if '__dateCreatedOnOrBefore__' in kwds: 
     148                return True 
    146149            if '__dateCreatedBefore__' in kwds: 
    147150                return True 
     
    191194            return records 
    192195        
    193         def createDomainObject(self, className, *args, **kwds): 
     196        def createDomainObject(self, className, __loadedList__=None, *args, **kwds): 
    194197            "Create new recorded domain object." 
    195198            newRecord = self.createRecord(className, *args, **kwds) 
     
    197200                message = "Created new db record. %s" % newRecord 
    198201                logger.debug(message) 
    199             newObject = newRecord.getDomainObject(
     202            newObject = newRecord.getDomainObject(loadedList=__loadedList__
    200203            return newObject 
    201204           
     
    491494                mapperAttributes['_table'] = self.dbName 
    492495        for a in self.attributes: 
     496            if a.dom.isTemporal: 
     497                continue 
    493498            mapperClassAttribute = a.createMapperClassAttribute() 
    494499            if mapperClassAttribute: 
     
    738743            logger.debug(message) 
    739744        self.domainObject.id = self.id 
     745        recordedTime = timepoint.recorded 
    740746        for metaAttr in self.meta.attributes: 
    741747            dbName = metaAttr.dbName 
     
    746752                ) 
    747753                logger.debug(message) 
    748             if metaAttr.isDomainObjectRef: 
     754            if metaAttr.dom.isTemporal: 
     755                r = metaAttr.dom.createTemporalCollection(self.domainObject) 
     756                mostRecent = r.findFirstDomainObject( 
     757                    __loadedList__=loadedList, 
     758                    __dateCreatedOnOrBefore__=recordedTime 
     759                ) 
     760                if mostRecent: 
     761                    mappedValue = mostRecent.recordedValue 
     762                else: 
     763                    mappedValue = metaAttr.dom.createInitialValue( 
     764                        self.domainObject 
     765                    ) 
     766            elif metaAttr.isDomainObjectRef: 
    749767                mapper = getattr(self, dbName) 
    750768                if mapper: 
     
    780798        isChanged = False 
    781799        for metaAttr in self.meta.attributes: 
    782             if metaAttr.isDomainObjectRef: 
     800            if metaAttr.dom.isTemporal: 
     801                domValue = getattr(self.domainObject, metaAttr.domName) 
     802                r = metaAttr.dom.createTemporalCollection(self.domainObject) 
     803                loadedList = {} 
     804                loadedList[self.domainObject] = self.domainObject 
     805                mostRecent = r.findFirstDomainObject(__loadedList__=loadedList) 
     806                #print "SAVE: Dom value (%s)" % (domValue) 
     807                if mostRecent != None: 
     808                    #print "SAVE: Most recent (%s)" % (mostRecent.recordedValue) 
     809                    if domValue != mostRecent.recordedValue: 
     810                        #print "SAVE: Stale version record. Creating new..." 
     811                        r.create(recordedValue=domValue, 
     812                            __loadedList__=loadedList) 
     813                    else: 
     814                        pass # print "SAVE: Fresh version record." 
     815                else: 
     816                    #print "SAVE: No version record. Creating new..." 
     817                    r.create(recordedValue=domValue,__loadedList__=loadedList) 
     818            elif metaAttr.isDomainObjectRef: 
    783819                domainObject = getattr(self.domainObject, metaAttr.domName) 
    784820                if domainObject and hasattr(domainObject, 'record'): 
     
    9691005                ) 
    9701006                sqlEqualsList.append(sqlEquals) 
     1007            elif name == '__dateCreatedOnOrBefore__': 
     1008                sqlSafeName = self.makeSqlName('date_created') 
     1009                sqlEquals = "%s <= %s" % ( 
     1010                    sqlSafeName, sqlSafeValue 
     1011                ) 
     1012                sqlEqualsList.append(sqlEquals) 
    9711013            elif name == '__dateCreatedAfter__': 
    9721014                sqlSafeName = self.makeSqlName('date_created') 
  • trunk/src/dm/dom/base.py

    r290 r296  
    245245                object.save() 
    246246        except KforgeDbError, inst: 
    247             raise KforgeDomError, inst  
     247            raise KforgeDomError, inst 
    248248        else: 
    249249            return object 
     
    282282            return None 
    283283     
    284     def findDomainObjects(self, **kwds): 
     284    def findDomainObjects(self, __loadedList__=None, **kwds): 
    285285        objectList = [] 
    286286        for record in self.findRecords(**kwds): 
    287             domainObject = record.getDomainObject(
     287            domainObject = record.getDomainObject(__loadedList__
    288288            objectList.append(domainObject) 
    289289        self.sortDomainObjects(objectList) 
     
    673673        self.decacheItem() 
    674674        if self.record: 
     675            self.deleteTemporalAttributeObjects() 
    675676            self.record.domainObject = None 
    676677            self.record.destroySelf() 
    677678            self.record = None 
     679 
     680    def deleteTemporalAttributeObjects(self): 
     681        for metaAttr in self.meta.attributes: 
     682            if metaAttr.isTemporal: 
     683                r = metaAttr.createTemporalCollection(self) 
     684                [i.delete() for i in r] 
    678685 
    679686    def purgeAggregates(self): 
  • trunk/src/dm/dom/meta.py

    r294 r296  
    112112 
    113113 
     114class TemporalCollection(object): 
     115 
     116    def __init__(self, register): 
     117        self.register = register 
     118 
     119    def __get__(self, obj, type=None): 
     120        print "Got __get__()" 
     121 
     122    def __set__(self, obj, value): 
     123        print "Got __set__(%s)" % value 
     124 
     125 
    114126class MetaDomainAttr(MetaBase): 
    115127    "Models a domain object attribute." 
     
    120132    isImageFile = False 
    121133 
    122     def __init__(self, typeName='', name='', dbName='', default=NotDefined, title='', comment='', isEditable=True, isHidden=False, isRequired=True, getChoices=None, isTemporal=False, isIndexed=False, **kwds): 
     134    def __init__(self, typeName='', name='', dbName='', default=NotDefined, title='', comment='', isEditable=True, isHidden=False, isRequired=True, getChoices=None, isTemporal=False, isBitemporal=False, isIndexed=False, **kwds): 
    123135        self.typeName = typeName 
    124136        self.name = name 
     
    139151        self.isIndexed = isIndexed 
    140152        self.isTemporal = isTemporal 
     153        if self.isIndexed and self.isTemporal: 
     154            raise Exception, "Can't be indexed and temporal, at the mo." 
     155        self.isBitemporal = isBitemporal 
     156        if self.isBitemporal: 
     157            self.isTemporal = True 
     158        self.isBitemporal = False  # Cut this out for the moment. 
     159        self.temporalDomainClass = None 
    141160 
    142161    def __repr__(self): 
     
    163182            setattr(domainObject, self.name, initialValue)  
    164183     
     184    def setTemporalDomainClass(self, domainClass): 
     185        self.temporalDomainClass = domainClass 
     186        self.temporalDomainClass.registerKeyName = 'dateCreated' 
     187        self.temporalDomainClass.isCached = True 
     188        self.temporalDomainClass.sortOnName = 'id' 
     189        self.temporalDomainClass.sortAscending = False 
     190 
     191    def createTemporalCollection(self, domainObject): 
     192        register = self.temporalDomainClass.createRegister() 
     193        register.ownerName = 'parent' 
     194        register.owner = domainObject 
     195        return register 
     196         
    165197    def createInitialValue(self, domainObject): 
    166198        return None 
     
    226258        dbValue = domainValue 
    227259        return dbValue 
     260 
     261    def duplicateTemporal(self): 
     262        attrMeta = self.duplicateSelf() 
     263        # Not bitemporal ATM. Just an idea for 'stepping down' the temporal:  
     264        if self.isBitemporal: 
     265             attrMeta.isTemporal = True 
     266             attrMeta.isBitemporal = False 
     267        else: 
     268             attrMeta.isTemporal = False 
     269        return attrMeta 
     270 
     271    def duplicateSelf(self): 
     272        return type(self)() 
    228273 
    229274 
     
    546591            self.logger.debug(msg) 
    547592        return attrValue 
     593 
     594    def duplicateSelf(self): 
     595        return type(self)(self.typeName) 
    548596 
    549597 
  • trunk/src/dm/dom/registry.py

    r272 r296  
    55from dm.exceptions import *  
    66import inspect 
     7import dm.times 
    78 
    89class DomainRegistry(AbstractList): 
     
    2930        domainClass = metaDomainObject.createDomainClass(baseClass) 
    3031        self.registerDomainClass(domainClass) 
     32        return domainClass 
    3133 
    3234    def getDomainClassRegister(self): 
     
    8284        for name in classRegister: 
    8385            self.checkHasAsForHasManys(classRegister[name]) 
     86        self.createTemporalAttributePersistence(domainClass.meta) 
     87 
     88    def createTemporalAttributePersistence(self, domainClassMeta): 
     89        temporalAttrs = [] 
     90        for a in domainClassMeta.attributes: 
     91            if a.isTemporal: 
     92                new = self.createTemporalDomainClass(domainClassMeta, a) 
     93                a.setTemporalDomainClass(new) 
     94 
     95    def createTemporalDomainClass(self, classMeta, attrMeta): 
     96        temporalClassName = classMeta.name + '_t_' + attrMeta.name 
     97        metaTemporalObject = DomainObject.metaClass(temporalClassName) 
     98        metaTemporalObject.recordedValue = attrMeta.duplicateTemporal() 
     99        metaTemporalObject.parent = HasA(classMeta.name, isRequired=True) 
     100        metaTemporalObject.dateCreated = DateTime(isIndexed=True, 
     101            isRequired=True, default=mx.DateTime.now) 
     102        return self.createDomainClass(metaTemporalObject) 
    84103 
    85104    def setMetaAttributesFromClass(self, domainClass, domainClassMeta): 
  • trunk/src/dm/dom/temporaltest.py

    r295 r296  
    22from dm.dom.testunit import TestCase 
    33from dm.exceptions import * 
    4 from dm.dom.stateful import SimpleNamedObject, String, DateTime 
     4from dm.dom.stateful import SimpleNamedObject, String, DateTime, HasA 
     5from dm.dom.base import DomainObjectRegister 
     6from dm.ioc import RequiredFeature 
     7import mx.DateTime 
     8from time import sleep 
    59 
    610def suite(): 
    711    suites = [ 
    8         unittest.makeSuite(TestTemporalAttributed), 
     12        unittest.makeSuite(TestTemporal), 
    913    ] 
    1014    return unittest.TestSuite(suites) 
     
    1317# Todo: Separate out the testing of indexes from testing of temporal attribute. 
    1418 
    15 class TemporalAttributed(SimpleNamedObject): 
     19class Temporal(SimpleNamedObject): 
    1620    "Temporally attributed domain object." 
    1721 
    18     name = String(default='', isTemporal=True, isIndexed=True) 
    19     description = String(default='', isTemporal=True, isIndexed=True) 
    20     dateTime = DateTime(isTemporal=True, isIndexed=True) 
    21  
    22  
    23 class TestTemporalAttributed(TestCase): 
    24     "TestCase for the TemporalAttributed class." 
     22    # Todo: Exception when register key attribute is temporal. 
     23    name = String(default='', isIndexed=True) 
     24    description = String(default='', isTemporal=True) 
     25    firstkiss = DateTime(isTemporal=True, default=mx.DateTime.now()) 
     26    state = HasA('State', isTemporal=True, isRequired=None) 
     27    haircolor = String(default='', isBitemporal=True) 
     28 
     29 
     30class TestTemporal(TestCase): 
     31    "TestCase for the Temporal class." 
     32 
     33    timepoint = RequiredFeature('Timepoint') 
    2534     
    2635    def setUp(self): 
    27         super(TestTemporalAttributed, self).setUp() 
    28         self.fixtureName = 'TestTemporalAttributed' 
    29         self.temporalAttributeds = self.registry.temporalAttributeds 
    30         try: 
    31             temporalAttributed = self.temporalAttributeds[self.fixtureName] 
    32             temporalAttributed.delete() 
    33             temporalAttributed.purge() 
    34         except: 
    35             self.temporalAttributed = self.temporalAttributeds.create(self.fixtureName) 
    36             self.fixture = self.temporalAttributed 
     36        super(TestTemporal, self).setUp() 
     37        self.fixtureName = 'TestTemporal' 
     38        self.temporals = self.registry.temporals 
     39        if self.fixtureName in self.temporals: 
     40            del(self.temporals[self.fixtureName]) 
     41        self.fixture = self.temporals.create(self.fixtureName) 
     42        self.temporal = self.fixture  
    3743        for i in range(1,5): 
    3844            newName = "%s%s" % (self.fixtureName, i) 
    39             self.temporalAttributeds.create(newName) 
     45            self.temporals.create(newName) 
    4046 
    4147    def tearDown(self): 
    4248        for i in range(1,5): 
    4349            newName = "%s%s" % (self.fixtureName, i) 
    44             del(self.temporalAttributeds[newName]) 
    45         try: 
    46             temporalAttributed = self.temporalAttributeds[self.fixtureName] 
    47             temporalAttributed.delete() 
    48             temporalAttributed.purge() 
    49         except: 
    50             pass 
    51         self.temporalAttributed = None 
     50            del(self.temporals[newName]) 
     51        if self.fixture: 
     52            fixture = self.fixture 
     53        if self.fixtureName in self.temporals: 
     54            del(self.temporals[self.fixtureName]) 
     55        self.temporal = None 
    5256 
    5357    def test_meta(self): 
    5458        metaAttr = self.fixture.meta.attributeNames['description'] 
    55         self.failUnlessEqual(metaAttr.isIndexed, True) 
    56         metaAttr = self.fixture.meta.attributeNames['dateTime'] 
    57         self.failUnlessEqual(metaAttr.isIndexed, True) 
     59        self.failUnlessEqual(metaAttr.isIndexed, False) 
     60        self.failUnlessEqual(metaAttr.isTemporal, True) 
     61        metaAttr = self.fixture.meta.attributeNames['firstkiss'] 
     62        self.failUnlessEqual(metaAttr.isIndexed, False) 
     63        self.failUnlessEqual(metaAttr.isTemporal, True) 
    5864        metaAttr = self.fixture.meta.attributeNames['name'] 
    5965        self.failUnlessEqual(metaAttr.isIndexed, True) 
     66        self.failUnlessEqual(metaAttr.isTemporal, False) 
    6067 
    6168    def test_new(self): 
    62         self.failUnless(self.temporalAttributed, "New temporalAttributed could not be created."
     69        self.failUnless(self.fixture
    6370        self.failUnlessRaises(KforgeDomError, 
    64             self.registry.temporalAttributeds.create, self.fixtureName 
     71            self.registry.temporals.create, self.fixtureName 
    6572        ) 
     73        self.failUnlessEqual(type(self.fixture.description), type("")) 
     74        self.failUnlessEqual(self.fixture.description, "") 
     75 
    6676 
    6777    def test_find(self): 
    68         self.failUnless(self.registry.temporalAttributeds['TestTemporalAttributed'], 
    69             "New temporalAttributed could not be found." 
     78        self.failUnless(self.registry.temporals['TestTemporal'], 
     79            "New temporal could not be found." 
    7080        ) 
    7181        self.failUnlessRaises(KforgeRegistryKeyError, 
    72             self.registry.temporalAttributeds.__getitem__, 'TestAlien' 
     82            self.registry.temporals.__getitem__, 'TestAlien' 
    7383        ) 
    7484 
    7585    def test_save(self): 
    76         self.assertEquals(self.temporalAttributed.description, "", "Already has a description.") 
    77         self.temporalAttributed.description = "Test TemporalAttributed" 
    78         self.assertEquals(self.temporalAttributed.description, "Test TemporalAttributed", 
    79             "TemporalAttributed doesn't have attribute." 
    80         ) 
    81         self.temporalAttributed.save() 
    82         temporalAttributed = self.temporalAttributeds[self.fixtureName] 
    83         self.assertEquals(temporalAttributed.description, "Test TemporalAttributed", 
    84             "Retrieved temporalAttributed has wrong description." 
    85         ) 
    86         temporalAttributed.description = "Other TemporalAttributed" 
    87         self.assertEquals(self.temporalAttributed.description, "Other TemporalAttributed", 
    88             "Suspect duplicate domain objects!!" 
    89         ) 
    90          
     86        self.failUnlessEqual(self.temporal.description, "", "Already has a description.") 
     87        self.temporal.description = "Test Temporal" 
     88        self.failUnlessEqual(self.temporal.description, "Test Temporal", "Temporal doesn't have attribute.") 
     89        self.temporal.save() 
     90        temporal = self.temporals[self.fixtureName] 
     91        self.failUnlessEqual(temporal.description, "Test Temporal") 
     92        temporal.description = "Other Temporal" 
     93        self.failUnlessEqual(self.temporal.description, "Other Temporal", "Suspect duplicate domain objects!!") 
     94        temporal.save() 
     95        self.failUnlessEqual(temporal.description, "Other Temporal", "Suspect broken temporal attribute: %s" % temporal.description) 
     96        temporal.save() 
     97        self.failUnlessEqual(temporal.description, "Other Temporal", "Suspect broken temporal attribute: %s" % temporal.description) 
     98        temporal.save() 
     99        temporal = self.temporals[self.fixtureName] 
     100        self.failUnlessEqual(temporal.description, "Other Temporal", "Suspect broken temporal attribute: %s" % temporal.description) 
     101 
     102        # Make changes to the recorded time. 
     103        state1 = self.registry.states['active'] 
     104        state2 = self.registry.states['pending'] 
     105        state3 = self.registry.states['deleted'] 
     106        time1 = mx.DateTime.DateTime(2007, 6, 1, 0, 0 ,0) 
     107        time2 = mx.DateTime.DateTime(2007, 7, 1, 0, 0 ,0) 
     108        time3 = mx.DateTime.DateTime(2007, 8, 1, 0, 0 ,0) 
     109        description1 = "Recent Description" 
     110        description2 = "Most Recent Description" 
     111        description3 = "Next Most Recent Description" 
     112        haircolor0 = "Ancient Haircolor" 
     113        haircolor1 = "Recent Haircolor" 
     114        haircolor2 = "Most Recent Haircolor" 
     115        haircolor3 = "Next Most Recent Haircolor" 
     116        haircolor4 = "Omg Next Most Recent Haircolor" 
     117        temporal.description = description1 
     118        temporal.firstkiss = time1 
     119        temporal.state = state1 
     120        temporal.haircolor = haircolor1 
     121        temporal.save() 
     122        revisionTime = mx.DateTime.now() 
     123        sleep(3) 
     124        temporal.description = description2 
     125        temporal.firstkiss = time2 
     126        temporal.state = state2 
     127        temporal.haircolor = haircolor2 
     128        temporal.save() 
     129        #  - check present is most recent 
     130        self.timepoint.reset() 
     131        temporal = self.temporals[self.fixtureName] 
     132        self.failUnlessEqual(temporal.description, description2) 
     133        self.failUnlessEqual(temporal.firstkiss, time2) 
     134        self.failUnlessEqual(temporal.state, state2) 
     135        self.failUnlessEqual(temporal.haircolor, haircolor2) 
     136        #  - check revisionTime is 'recent' 
     137        self.timepoint.recorded = revisionTime 
     138        temporal = self.temporals[self.fixtureName] 
     139        self.failUnlessEqual(temporal.description, description1) 
     140        self.failUnlessEqual(temporal.firstkiss, time1) 
     141        self.failUnlessEqual(temporal.state, state1) 
     142        self.failUnlessEqual(temporal.haircolor, haircolor1) 
     143        #  - check we can return to the present 
     144        self.timepoint.reset() 
     145        temporal = self.temporals[self.fixtureName] 
     146        self.failUnlessEqual(temporal.description, description2) 
     147        self.failUnlessEqual(temporal.firstkiss, time2) 
     148        self.failUnlessEqual(temporal.state, state2) 
     149        self.failUnlessEqual(temporal.haircolor, haircolor2) 
     150        #  - check a new value comes through ok 
     151        temporal.description = description3 
     152        temporal.firstkiss = time3 
     153        temporal.state = state3 
     154        temporal.haircolor = haircolor3 
     155        temporal.save() 
     156        temporal = self.temporals[self.fixtureName] 
     157        self.failUnlessEqual(temporal.description, description3) 
     158        self.failUnlessEqual(temporal.firstkiss, time3) 
     159        self.failUnlessEqual(temporal.state, state3) 
     160        self.failUnlessEqual(temporal.haircolor, haircolor3) 
     161 
     162        # Make changes to the actual time. 
     163 
     164 
     165        return 
     166 
     167 
     168        self.timepoint.reset() 
     169        temporal = self.temporals[self.fixtureName] 
     170        self.failUnlessEqual(temporal.haircolor, haircolor3) 
     171        yearsAgo = mx.DateTime.DateTime(2001, 6, 1, 0, 0, 0) 
     172        self.timepoint.actual = yearsAgo 
     173        temporal.haircolor = haircolor0 
     174        temporal.save() 
     175        temporal = self.temporals[self.fixtureName] 
     176        self.failUnlessEqual(temporal.haircolor, haircolor0) 
     177        self.timepoint.reset() 
     178        temporal = self.temporals[self.fixtureName] 
     179        self.failUnlessEqual(temporal.haircolor, haircolor3) 
     180        self.timepoint.actual = yearsAgo 
     181        temporal = self.temporals[self.fixtureName] 
     182        self.failUnlessEqual(temporal.haircolor, haircolor0) 
     183        self.timepoint.reset() 
     184        temporal = self.temporals[self.fixtureName] 
     185        self.failUnlessEqual(temporal.haircolor, haircolor3) 
     186        self.timepoint.recorded = revisionTime 
     187        self.timepoint.actual = yearsAgo 
     188        temporal = self.temporals[self.fixtureName] 
     189        self.failUnlessEqual(temporal.haircolor, '') 
     190        self.timepoint.reset() 
     191        self.timepoint.recorded = revisionTime 
     192        temporal = self.temporals[self.fixtureName] 
     193        self.failUnlessEqual(temporal.haircolor, haircolor1) 
     194 
    91195    def test_count(self): 
    92         self.failUnless(self.temporalAttributeds.count(), "Problem with temporalAttributed count.") 
     196        self.failUnless(self.temporals.count(), "Problem with temporal count.") 
    93197 
    94198    def test_keys(self): 
    95         self.failUnless(self.temporalAttributeds.keys(), "Problem with temporalAttributed list.") 
     199        self.failUnless(self.temporals.keys(), "Problem with temporal list.") 
    96200 
    97201    def test_iter(self): 
    98         self.failUnless(self.temporalAttributeds.__iter__(), "Problem with temporalAttributed iter.") 
    99         for p in self.temporalAttributeds: 
    100             self.failUnless(p.name, "Problem with iteration temporalAttributed: %s" % p) 
     202        self.failUnless(self.temporals.__iter__(), "Problem with temporal iter.") 
     203        for p in self.temporals: 
     204            self.failUnless(p.name, "Problem with iteration temporal: %s" % p) 
    101205 
    102206    def test_getNextObject(self): 
    103         temporalAttributedList = self.temporalAttributeds.getSortedList() 
    104         lenList = len(temporalAttributedList) 
     207        temporalList = self.temporals.getSortedList() 
     208        lenList = len(temporalList) 
    105209        self.failUnless(lenList >= 4, lenList) 
    106         temporalAttributed = temporalAttributedList[-3] 
    107         nextTemporalAttributed = self.temporalAttributeds.getNextObject(temporalAttributedList, temporalAttributed
    108         self.failUnlessEqual(nextTemporalAttributed, temporalAttributedList[-2]) 
    109         nextTemporalAttributed = self.temporalAttributeds.getNextObject(temporalAttributedList, nextTemporalAttributed
    110         self.failUnlessEqual(nextTemporalAttributed, temporalAttributedList[-1]) 
    111         nextTemporalAttributed = self.temporalAttributeds.getNextObject(temporalAttributedList, nextTemporalAttributed
    112         self.failIf(nextTemporalAttributed
     210        temporal = temporalList[-3] 
     211        nextTemporal = self.temporals.getNextObject(temporalList, temporal
     212        self.failUnlessEqual(nextTemporal, temporalList[-2]) 
     213        nextTemporal = self.temporals.getNextObject(temporalList, nextTemporal
     214        self.failUnlessEqual(nextTemporal, temporalList[-1]) 
     215        nextTemporal = self.temporals.getNextObject(temporalList, nextTemporal
     216        self.failIf(nextTemporal
    113217         
    114218    def test_getPreviousObject(self): 
    115         temporalAttributedList = self.temporalAttributeds.getSortedList() 
    116         lenList = len(temporalAttributedList) 
     219        temporalList = self.temporals.getSortedList() 
     220        lenList = len(temporalList) 
    117221        self.failUnless(lenList >= 4, lenList) 
    118         temporalAttributed = temporalAttributedList[2] 
    119         previousTemporalAttributed = self.temporalAttributeds.getPreviousObject(temporalAttributedList, temporalAttributed
    120         self.failUnlessEqual(previousTemporalAttributed, temporalAttributedList[1]) 
    121         previousTemporalAttributed = self.temporalAttributeds.getPreviousObject(temporalAttributedList, previousTemporalAttributed
    122         self.failUnlessEqual(previousTemporalAttributed, temporalAttributedList[0]) 
    123         previousTemporalAttributed = self.temporalAttributeds.getPreviousObject(temporalAttributedList, previousTemporalAttributed
    124         self.failIf(previousTemporalAttributed
    125  
    126  
     222        temporal = temporalList[2] 
     223        previousTemporal = self.temporals.getPreviousObject(temporalList, temporal
     224        self.failUnlessEqual(previousTemporal, temporalList[1]) 
     225        previousTemporal = self.temporals.getPreviousObject(temporalList, previousTemporal
     226        self.failUnlessEqual(previousTemporal, temporalList[0]) 
     227        previousTemporal = self.temporals.getPreviousObject(temporalList, previousTemporal
     228        self.failIf(previousTemporal
     229 
     230 
  • trunk/src/dm/test.py

    r254 r296  
    11import dm.timestest 
     2import dm.timepointtest 
    23import dm.strategytest 
    34import dm.environmenttest 
     
    2324    suites = [ 
    2425        dm.timestest.suite(), 
     26        dm.timepointtest.suite(), 
    2527        dm.strategytest.suite(), 
    2628        dm.environmenttest.suite(), 
  • trunk/src/dm/testunit.py

    r294 r296  
    2222    def construct(self): 
    2323        super(ModelBuilder, self).construct() 
    24         self.loadTemporalAttributed() 
     24        self.loadTemporal() 
    2525 
    26     def loadTemporalAttributed(self): 
    27         from dm.dom.temporaltest import TemporalAttributed 
    28         self.registry.registerDomainClass(TemporalAttributed
    29         self.registry.temporalAttributeds = TemporalAttributed.createRegister() 
     26    def loadTemporal(self): 
     27        from dm.dom.temporaltest import Temporal 
     28        self.registry.registerDomainClass(Temporal
     29        self.registry.temporals = Temporal.createRegister() 
    3030 
    3131