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

12.4. FormPhotoSet.pathName(): Form page relative path name

This method returns the path name of this form's form page, relative to the index page. Python's os.path.join() function is used to mate the directory and file names. The file name is based on the bird code from self.birdId, but we must sanitize it by translating the relationship codes. The class variable relMap maps those codes onto strings acceptable for use in file names.

catweb
# - - -   F o r m P h o t o S e t . p a t h N a m e

    relMap = { abbrModule.REL_HYBRID: "-x-",
                 abbrModule.REL_PAIR:   "-o-" }

    def pathName(self):
        '''Returns the relative path name of self's form page.
        '''

        #-- 1
        # [ if self.birdId.rel is None ->
        #     basename  :=  self.birdId.abbr
        #   else ->
        #     basename  :=  self.birdId.abbr +
        #         (self.birdId.rel, translated using self.relMap) +
        #         self.birdId.abbr2 ]
        if  self.birdId.rel is abbrModule.REL_SIMPLE:
            basename = self.birdId.abbr.rstrip().lower()
        else:
            cleanRel = self.relMap[self.birdId.rel]
            basename  = ("%s%s%s" %
                           (self.birdId.abbr.rstrip().lower(), cleanRel,
                            self.birdId.abbr2.rstrip().lower()))

To distinguish questionable forms, we add "-q" to the end in that case.

catweb
        #-- 2
        if  self.birdId.q:  suffix = "-q"
        else:               suffix = ""

For the name of the forms subdirectory, see Section 9.14, “FORM_SUBDIR: Form subdirectory name”.

catweb
        #-- 2
        # [ return FORM_SUBDIR + basename + ".html" ]
        path = os.path.join(FORM_SUBDIR, basename)
        return  "%s%s.html" % (path, suffix)