First page Back Continue Last page Overview Graphics
Dimension
class Dimension( object ):
"""A collection of related entities.
- This could be mapped to an RDBMS table.
- """
def __init__( self, entityMap=None ):
self.entityMap= entityMap or {}
def makeEntity( self, *levelsTuple ):
return Entity(*levelsTuple)
def items( self ):
return self.entityMap.items()
def conform( self, *levelsTuple ):
"""Conform these values to this dimension.
This may create a new Entity
or return an existing Entity.
tentative= self.makeEntity( *levelsTuple )
actual= self.entityMap.setdefault(
tentative.level,
tentative )
actual.dimension= self
return actual