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

10.40. HistArgs._allSelected(): Report on selected circles

# - - -   H i s t A r g s . _ a l l S e l e c t e d

    def _allSelected(self, form):
        '''Find the checkboxes of selected circles.

          [ form is a cgi.FieldStorage instance ->
              if (form has at least one key LAT_LON) and
              (the LAT_LON values are "ddmm-DDDMM" coordinates) ->
                self.latLonList  :=  those coordinates as a list of
                    ("ddmm", "DDDMM") tuples
              else -> raise ScriptError ]

First we need to find all the selected circle checkboxes, if any. The FieldStorage.getlist() method is just what we need. Whether the form has no values, one values, or multiple values for the given element, we always get back a list. If the user forgot to check any circle checkboxes, it's an error.

        #-- 1
        # [ rawList  :=  list of all values of LAT_LON in form ]
        rawList = form.getlist(regform.LAT_LON)

        #-- 2
        if len(rawList) == 0:
            raise lib.ScriptError("You must select at least one index "
                "entry's checkbox to get a history report.")

For the logic that tests each value for the correct format, see Section 10.41, “HistArgs._checkLatLon(): Check one lat-lon argument”.

        #-- 3
        # [ if all elements of rawList are center coordinates in
        #   "ddmm-DDDMM" format ->
        #     result  :=  those values as a list of ("ddmm", "DDDMM")
        #                 tuples
        #   else -> raise ScriptError ]
        result = [ self._checkLatLon(raw)
                   for raw in rawList ]

        #-- 4
        return result