Exemplo n.º 1
0
    def updateAttribute(self, form):
        db = self.__db
        cursor = self.__cursor
        hostname = self.__hostname

        lHandler = LocationHandler(db, cursor)
        prepPropMapper = PrepPropertyMapper(db, cursor)
        prepProp_Name_ID_Map = prepPropMapper.mapPrepPropNameToID()

        #print "Content-type:text/html"

        # Update the given attribute for each well selected
        wells_str = form.getvalue(
            "wells")  # it's a comma-delimited string, count as one value

        contID = int(form.getvalue("contID"))
        propName = form.getvalue("propName")
        propVal = form.getvalue("propVal")

        if prepProp_Name_ID_Map.has_key(propName):
            prepElemID = prepProp_Name_ID_Map[propName]
        else:
            prepElemID = 0
        '''
		if form.has_key("propID"):
			try:
				prepElemID = int(form.getvalue("propID"))

			except ValueError:
				prepElemID = 0
		'''

        # wells are provided as a comma-delimited list of 'row|col' values
        wells = wells_str.split(",")

        for well in wells:
            coords = well.split('|')

            wellRow = coords[0]
            wellCol = coords[1]

            wellID = lHandler.findWellIDByCoordinates(contID, wellRow, wellCol)
            #print wellID

            # get its prep
            prepID = lHandler.findPrepIDInWell(wellID)

            # Differentiate between update of prep element or reference/comments
            if prepElemID > 0:
                lHandler.updatePrepPropertyValue(prepID, prepElemID, propVal)
            else:
                if propName.lower() == 'reference':
                    lHandler.updatePrepReference(prepID, propVal)

                elif propName.lower() == 'comments':
                    lHandler.updatePrepComments(prepID, propVal)

        #utils.redirect(hostname + "Location.php?View=2&Mod=" + `contID`)
        print hostname + "Location.php?View=2&Mod=" + ` contID `