Next / Previous / Contents / TCC Help System / NM Tech homepage

12.2. FormPhotoSet.addArchImage(): Add one photo

To add a new ArchImage object to this FormPhotoSet instance, we construct the 2-tuple used as a key to self._sizeMap, then store the ArchImage under that key. There shouldn't be any duplications, but let's check anyway.

catweb
# - - -   F o r m P h o t o S e t . a d d A r c h I m a g e

    def addArchImage(self, archImage):
        '''Add a new archived, cataloged image to self.
        '''
        #-- 1
        # [ area  :=  number of pixels in archImage ]
        area = archImage.wide * archImage.high

        #-- 2
        # [ key  := (-area, catalog number from archImage) ]
        key  = (-area, archImage.original.catNo)

        #-- 3
        if  self._sizeMap.has_key(key):
            raise KeyError("Duplicate form photo: area %dpx, "
                "catalog number %s" %
                (area, archImage.original.catNo))
        else:
            self._sizeMap[key] = archImage