def readForm(self, fd):
		newRecord = {}
		for field in self.db.disfield:
			fieldValue = fd.formdata.getvalue(field)
			if field == 'name' or field == 'sequence':
				fieldValue = None
			elif (not fieldValue) and (field == 'post_publication_description' or field == 'authors' or field == 'title' or field=='year'):
				heading = "Add to Published Database"
				detail = ["You did not enter information for %s." % webqtlUtil.formatField(field)]
				self.error(heading=heading,detail=detail,error="Error")
				return {}
			elif fieldValue and field == 'pubmed_id':
				try:
					fieldValue = int(fieldValue)
				except:
					fieldValue = None
			else:
				pass
			newRecord[field] = fieldValue
		return newRecord
	def dispFormPage(self, fd):
		###specical care, temporary trait data
		fullname =  fd.formdata.getvalue('fullname')
		if fullname:
			thisTrait = webqtlTrait(fullname=fullname, data= fd.allTraitData, cursor=self.cursor)
			thisTrait.retrieveInfo()
			PhenotypeValue = thisTrait.description
		else:
			thisTrait = webqtlTrait(data= fd.allTraitData)
			PhenotypeValue = thisTrait.identification
			
		self.dict['title'] = 'Add to Published Database'
		
		form = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='dataInput',submit=HT.Input(type='hidden'))

		recordTable = HT.TableLite(border=0, align="left")
		recordInfoContainer = HT.Div(align="left")
		recordDataContainer = HT.Div(align="left")
		title1 = HT.Paragraph(" Trait Information:", align="left", Class="subtitle")
		title2 = HT.Paragraph(" Trait Data:", align="left", Class="subtitle")
		addButton = HT.Input(type='submit',name='submit', value='Submit Trait',Class="button")
		resetButton = HT.Input(type='reset',Class="button")

		recordInfoTable = HT.TableLite(border=0, cellspacing=1, cellpadding=5,align="left")
		for field in self.db.disfield:
			fieldValue = ""

			if field == 'comments':
				continue
			elif field == 'name' or field == 'sequence' or field == 'original_description' or field == 'submitter' or field == 'authorized_users':
				form.append(HT.Input(type="hidden",name=field,value=fieldValue))
				continue
			elif field == 'post_publication_description':
				inputBox = HT.Textarea(name=field, cols=60, rows=6,text=PhenotypeValue)
			elif field == 'abstract' or field == 'pre_publication_description' or field == 'owner':
				inputBox = HT.Textarea(name=field, cols=60, rows=6,text=fieldValue)
			elif field == 'post_publication_abbreviation' or field == 'pre_publication_abbreviation':
				inputBox = HT.Input(type="text",name=field,size=60, maxlength=30,value=fieldValue)
			else:
				inputBox = HT.Input(type="text",name=field,size=60, maxlength=255,value=fieldValue)
			if field in ('post_publication_description', 'authors', 'title', 'year'):
				requiredSign = HT.Span('*', Class="cr")
			else:
				requiredSign = ''
				
			recordInfoTable.append(HT.TR(
				HT.TD(requiredSign, "%s :" % webqtlUtil.formatField(field), Class="fs12 fwb ff1", valign="top",align="right"),
				HT.TD(width=20),HT.TD(inputBox)))

			if field == 'pubmed_id':
				recordInfoTable.append(HT.TR(
				HT.TD(), HT.TD(width=20), 
				HT.TD("Do not enter PubMed_ID if this trait has not been Published.", 
					HT.BR(), "If the PubMed_ID you entered is alreday stored in our database, ",
					HT.BR(), "all the following fields except Post Publication Description will be ignored.",
					HT.BR(), "Do not enter any non-digit character in this field.", Class="fs11 cr")
				))
			if field == 'pre_publication_description':
				recordInfoTable.append(HT.TR(
				HT.TD(), HT.TD(width=20),
				HT.TD("If the PubMed ID is entered, the Post Publication Description will be shown to all",
					HT.BR(), " users. If there is no PubMed ID, and the Pre Publication Description is entered,",
					HT.BR(), "only you and authorized users can see the Post Publication Description.", Class="fs11 cr")
				))
			if field == 'owner':
				recordInfoTable.append(HT.TR(
				HT.TD(), HT.TD(width=20),
				HT.TD("Please provide detailed owner contact information including full name, title,",
                                        HT.BR(), " institution, address, email etc", Class="fs11 cr")
				))

		recordInfoTable.append(HT.TR(HT.TD(HT.Span('*', Class="cr"), " Required field", align="center", colspan=3)))
		recordInfoContainer.append(addButton, resetButton, HT.P(), title1, HT.BR(), recordInfoTable)

		recordDataTable = HT.TableLite(border=0, width = "90%",cellspacing=2, cellpadding=2)
		recordDataTable.append(HT.TR(HT.TD('Strain Name',Class="fs12 ffl fwb",align="left"), 
			HT.TD('Trait Data',Class="fs12 ffl fwb",align="right"), 
			HT.TD('SE',Class="fs12 ffl fwb",align="right"),
			HT.TD('N Per Strain',Class="fs12 ffl fwb",align="right"),
			HT.TD('&nbsp'*8,Class="fs12 ffl fwb",align="center"),
			HT.TD('Strain Name',Class="fs12 ffl fwb",align="left"), 
			HT.TD('Trait Data',Class="fs12 ffl fwb",align="right"), 
			HT.TD('SE',Class="fs12 ffl fwb",align="right"),
			HT.TD('N Per Strain',Class="fs12 ffl fwb",align="right")))
		
		tempTR = HT.TR(align="right")
		for i, strainName in enumerate(fd.strainlist):
			if thisTrait.data.has_key(strainName):
				tdata = thisTrait.data[strainName]
				traitVal, traitVar, traitNP = tdata.val, tdata.var, tdata.N
			else:
				traitVal, traitVar, traitNP = None, None, None
			
			if traitVal != None:	
				traitVal = "%2.3f" % traitVal
			else:
				traitVal = 'x'
			if traitVar != None:	
				traitVar = "%2.3f" % traitVar
			else:
				traitVar = 'x'
			if traitNP != None:	
				traitNP = "%d" % traitNP
			else:
				traitNP = 'x'

			tempTR.append(HT.TD(HT.Paragraph(strainName), width="120px", align='left'), \
				HT.TD(HT.Input(name=fd.strainlist[i], size=8, maxlength=8, value=traitVal, align="right"), width="100px", align='right'),
				HT.TD(HT.Input(name='V'+fd.strainlist[i], size=8, maxlength=8, value=traitVar, align="right"), width="100px", align='right'),
				HT.TD(HT.Input(name='N'+fd.strainlist[i], size=8, maxlength=8, value=traitNP, align="right"), width="120px", align='right'),
				HT.TD('', align='center'))
			if i % 2:
				recordDataTable.append(tempTR)
				tempTR = HT.TR(align="Center")
		
		if (i+1) % 2:
			tempTR.append(HT.TD(''))
			tempTR.append(HT.TD(''))
			tempTR.append(HT.TD(''))
			recordDataTable.append(tempTR)

		recordDataContainer.append(title2, HT.BR(), recordDataTable, HT.P(), addButton, resetButton, HT.P())

		recordTable.append(HT.TR(HT.TD(recordInfoContainer)), HT.TR(HT.TD(recordDataContainer)))

		"""
		"""
		
		hddn = {'database':self.db.name, 'curStatus':'insertCheck', 'FormID':'dataEditing', 'submitID':'addPublish', 'RISet':fd.RISet}
		for key in hddn.keys():
			form.append(HT.Input(name=key, value=hddn[key], type='hidden'))

		
		#############################
		TD_LR = HT.TD(valign="top",colspan=2,bgcolor="#ffffff")
		
		mainTitle = HT.Paragraph("Add Trait to Published Database", Class="title")
		
		form.append(recordTable)
		
		TD_LR.append(mainTitle, form)
		
		self.dict['body'] = TD_LR
	def insertCheckPage(self, fd, newRecord):
		#generate html
		form = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='dataInput',submit=HT.Input(type='hidden'))
		hddn = {'database':self.db.name, 'curStatus':'insertResult', 'FormID':'dataEditing', 'submitID':'addPublish', 'RISet':fd.RISet}
		
		recordTable = HT.TableLite(border=0, align="left")
		title1 = HT.Paragraph("Trait Information:", Class="subtitle")
		title2 = HT.Paragraph("Trait Data:", Class="subtitle")
		recordInfoContainer = HT.Div(align="left")
		recordDataContainer = HT.Div(align="left")
		addButton = HT.Input(type='submit',name='submit', value='Add to Publish',Class="button")
		resetButton = HT.Input(type='reset',Class="button")

		recordInfoTable = HT.TableLite(border=0, cellspacing=1, cellpadding=5, align="left")
		for field in self.db.disfield:
			if newRecord[field]:
				recordInfoTable.append(HT.TR(
					HT.TD("%s :" % webqtlUtil.formatField(field), Class="fs12 fwb ff1", valign="top",align="right"),
					HT.TD(width=20),HT.TD(newRecord[field])))
				hddn[field] = newRecord[field]

		recordInfoContainer.append(addButton, resetButton, HT.P(), title1, HT.BR(), recordInfoTable)
		
		recordDataTable = HT.TableLite(border=0, width = "80%",cellspacing=3, cellpadding=2)	
		recordDataTable.append(HT.TR(HT.TD('Strain Name',Class="fs12 ffl fwb",align="left"), 
			HT.TD('TraitData',Class="fs12 ffl fwb",align="right"), 
			HT.TD('SE',Class="fs12 ffl fwb",align="right"),
			HT.TD('N Per Strain',Class="fs12 ffl fwb",align="right"),
			HT.TD('&nbsp'*8,Class="fs12 ffl fwb",align="center"),
			HT.TD('Strain Name',Class="fs12 ffl fwb",align="left"), 
			HT.TD('TraitData',Class="fs12 ffl fwb",align="right"), 
			HT.TD('SE',Class="fs12 ffl fwb",align="right"),
			HT.TD('N Per Strain',Class="fs12 ffl fwb",align="right")))
		
		tempTR = HT.TR(align="Center")
		for i, strainName in enumerate(fd.strainlist):
			if fd.allTraitData.has_key(strainName):
				tdata = fd.allTraitData[strainName]
				traitVal, traitVar, traitNP = tdata.val, tdata.var, tdata.N
			else:
				traitVal, traitVar, traitNP = None, None, None
			
			if traitVal != None:	
				traitVal = "%2.3f" % traitVal
			else:
				traitVal = 'x'
			if traitVar != None:	
				traitVar = "%2.3f" % traitVar
			else:
				traitVar = 'x'
			if traitNP != None:	
				traitNP = "%d" % traitNP
			else:
				traitNP = 'x'
					
			tempTR.append(HT.TD(HT.Paragraph(strainName),align='left'), 
				HT.TD(traitVal,align='right'), 
				HT.TD(traitVar,align='right'),
				HT.TD(traitNP,align='right'),
				HT.TD('',align='center'))
			if i % 2:
				recordDataTable.append(tempTR)
				tempTR = HT.TR(align="Center")
				
		if (i+1) % 2:
			tempTR.append(HT.TD(''))
			tempTR.append(HT.TD(''))
			recordDataTable.append(tempTR)

		info = HT.Paragraph("Please review the trait information and data in the text below. Check the values for errors. If no error is found, please click the \"Add to Publish\" button to submit it.")
		recordDataContainer.append(title2, HT.BR(), info, HT.P(), recordDataTable, HT.P(), addButton, resetButton, HT.P())

		recordTable.append(HT.TR(HT.TD(recordInfoContainer)), HT.TR(HT.TD(recordDataContainer)))			

		webqtlUtil.exportData(hddn, fd.allTraitData, 1)
		for key in hddn.keys():
			form.append(HT.Input(name=key, value=hddn[key], type='hidden'))

		
		#############################
		TD_LR = HT.TD(valign="top",colspan=2,bgcolor="#ffffff")
		
		mainTitle = HT.Paragraph("Add Trait to Published Database", Class="title")

		form.append(recordTable)
		
		TD_LR.append(mainTitle, HT.Blockquote(form))
		
		self.dict['body'] = TD_LR
	def dispTraitPage(self, fd, thisTrait):	
		form = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='dataInput',submit=HT.Input(type='hidden'))

		#XZhou: This is to show trait info.
		recordInfoTable = HT.TableLite(border=0, cellspacing=1, cellpadding=5,align="left")

		for field in thisTrait.db.disfield:
			fieldValue = getattr(thisTrait, field)
			if not fieldValue:
				fieldValue = ""
			#fields to be ignored
			if field in ("chipid", "genbankid"):
				continue
			elif field == "comments":
				if fieldValue:
					comments = string.split(fieldValue, '\n')
					title0 = HT.Paragraph("Update History: ", Class="subtitle")
					form.append(title0)
					history = HT.Blockquote()
					for item in comments:
						if item:
							history.append(item, HT.BR())
					form.append(history)
				continue
			else:
				pass
				
			if field == 'name' or field == 'units':
				form.append(HT.Input(type="hidden",name=field,value=fieldValue))
				if field == 'name':
					inputBox = HT.Strong(fieldValue)
				else:
					continue
			elif field == 'pubmed_id':
				inputBox = HT.Span(HT.Input(type="text",name=field,size=60, maxlength=255,value=fieldValue))
				warning = HT.Paragraph(Class="fs11 cr")
				warning.append('1. Please enter only the PubMed ID integer value into the field above.', HT.BR(), '    Don\'t enter',
							' other characters.', HT.BR()) 
				warning.append('2. If you modify an existing PubMed ID, changes will affect other records with', HT.BR(), \
							'    the same ID but will NOT affect the phenotype description or trait data.', HT.BR()) 
				warning.append('3. If your delete an existing PubMed ID, this will not affect any other traits,', HT.BR(), \
							'    including those with the same PubMed ID.', HT.BR()) 
				warning.append('4. If you enter publication data for a PubMed ID that is already in the database,', HT.BR(), \
							'    then all fields except Phenotype and Trait Data will be ignored.') 
				inputBox.append(warning)
			elif field == 'pre_publication_description' or field == 'post_publication_description' or field == 'original_description' or field == 'owner' or field == 'abstract' or field == 'blatseq' or field == 'targetseq' or field == 'description' or field == 'authors' or field == 'sequence' or field == 'alias' or field == 'probe_target_description':
				inputBox = HT.Textarea(name=field, cols=60, rows=4,text=fieldValue)
			elif field == 'post_publication_abbreviation' or field == 'pre_publication_abbreviation':
				inputBox = HT.Input(type="text",name=field,size=60, maxlength=30,value=fieldValue)
			elif field == 'geneid':
				inputBox = HT.Input(type="text",name=field,size=60, maxlength=255,value=fieldValue)
				recordInfoTable.append(HT.TR(
                                HT.TD("%s :" % webqtlUtil.formatField(field), Class="fs12 fwb ff1", align="right"),
                                HT.TD(width=20),HT.TD(inputBox)))
				#XZ: homologene is not in thisTrait.db.disfield, so have to do in this way
				field = 'homologeneid'
				inputBox = HT.Input(type="text",name=field,size=60, maxlength=255,value=thisTrait.homologeneid)
			else:
				inputBox = HT.Input(type="text",name=field,size=60, maxlength=255,value=fieldValue)

			#XZ: For existing non-confidential phenotype trait, pre_publication_description and pre_publication_abbreviation are not shown to anybody except submitter or admistrator to prevent the trait being set to confidential one.
			if thisTrait.db.type == 'Publish' and field == 'pre_publication_description' or field == 'pre_publication_abbreviation':
				if not thisTrait.confidential and webqtlConfig.USERDICT[self.privilege] < webqtlConfig.USERDICT['admin'] and self.userName != thisTrait.submitter:
					continue

			#XZ and Rob, April 20, 2011: This is to add field and inputBox to table. Note that the change of format to each field(Capitalize) by webqtlUtil.formatField function.
			recordInfoTable.append(HT.TR(
				HT.TD("%s :" % webqtlUtil.formatField(field), Class="fs12 fwb ff1", align="right", valign="top"),
				HT.TD(width=5),HT.TD(inputBox)))

		#XZhou: This is to show trait data.
		recordDataTable = HT.Text('Trait data updating is disabled')
		
		if thisTrait.db.type == 'Publish':
			thisTrait.retrieveData()
			recordDataTable = HT.TableLite(border=0, width = "90%",cellspacing=2, cellpadding=2)
			recordDataTable.append(HT.TR(HT.TD('Strain Name',Class="fs12 ffl fwb",align="Center"), 
				HT.TD('TraitData',Class="fs12 ffl fwb",align="Center"), 
				HT.TD('SE',Class="fs12 ffl fwb",align="Center"),
				HT.TD('N Per Strain',Class="fs12 ffl fwb",align="Center"),
				HT.TD('Strain Name',Class="fs12 ffl fwb",align="Center"), 
				HT.TD('TraitData',Class="fs12 ffl fwb",align="Center"), 
				HT.TD('SE',Class="fs12 ffl fwb",align="Center"),
				HT.TD('N Per Strain',Class="fs12 ffl fwb",align="Center")))
			tempTR = HT.TR(align="Center")
			for i, strainName in enumerate(fd.strainlist):
				if thisTrait.data.has_key(strainName):
					tdata = thisTrait.data[strainName]
					traitVal, traitVar, traitNP = tdata.val, tdata.var, tdata.N
				else:
					traitVal, traitVar, traitNP = None, None, None
				
				if traitVal != None:	
					traitVal = "%2.3f" % traitVal
				else:
					traitVal = 'x'
				if traitVar != None:	
					traitVar = "%2.3f" % traitVar
				else:
					traitVar = 'x'
				if traitNP != None:	
					traitNP = "%d" % traitNP
				else:
					traitNP = 'x'
						
				tempTR.append(HT.TD(HT.Paragraph(strainName),align='CENTER'), 
					HT.TD(HT.Input(name=strainName, size=8, maxlength=8, value=traitVal),align='CENTER'),
					HT.TD(HT.Input(name='V'+strainName, size=8, maxlength=8, value=traitVar),align='CENTER'),
					HT.TD(HT.Input(name='N'+strainName, size=8, maxlength=8, value=traitNP),align='CENTER'))
				if i % 2:
					recordDataTable.append(tempTR)
					tempTR = HT.TR(align="Center")
			
			if (i+1) % 2:
				tempTR.append(HT.TD(''))
				tempTR.append(HT.TD(''))
				tempTR.append(HT.TD(''))
				recordDataTable.append(tempTR)
					
		updateButton = HT.Input(type='submit',name='submit', value='Submit Change',Class="button")
		resetButton = HT.Input(type='reset',Class="button")
		
		hddn = {'fullname':str(thisTrait), 'FormID':'updateRecord', 'curStatus':'updateCheck', 'RISet':fd.RISet, "incparentsf1":1}
		for key in hddn.keys():
			form.append(HT.Input(name=key, value=hddn[key], type='hidden'))

		
		#############################
		TD_LR = HT.TD(valign="top",colspan=2,bgcolor="#eeeeee")

		containerTable = HT.TableLite(border=0, width = "90%",cellspacing=0, cellpadding=0)
		
		mainTitle = HT.Paragraph("Update Info and Data", Class="title")
		
		title1 = HT.Paragraph("Trait Information: ", Class="subtitle")

		title2 = HT.Paragraph("Trait Data:", Class="subtitle")

		containerTable.append(HT.TR(HT.TD(title1)), HT.TR(HT.TD(HT.BR(),updateButton,resetButton,HT.BR(),HT.BR())), 
					 HT.TR(HT.TD(recordInfoTable)), HT.TR(HT.TD(title2)), HT.TR(HT.TD(HT.BR(),recordDataTable, HT.BR(), HT.BR())),
					 HT.TR(HT.TD(updateButton,resetButton)))
		
		form.append(containerTable)
		
		TD_LR.append(mainTitle, form)
		
		self.dict['body'] = TD_LR
	def updateCheckPage(self, fd, thisTrait):
		form = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), name='updateCheck',submit=HT.Input(type='hidden'))
		hddn = {'fullname':str(thisTrait), 'FormID':'updateRecord', 'curStatus':'updateResult', 'RISet':fd.RISet, "incparentsf1":1}
		
		recordInfoTable = HT.TableLite(border=0, cellspacing=1, cellpadding=5,align="left",width="90%")
		infoChanges = []
		for field in thisTrait.db.disfield:
			#fields to be ignored
			#XZ: The stupid htmlgen can not set readonly for input and textarea. This is the only way I can prevent displayed items such as 'original_description', 'submitter' being changed.
			if field in ("chipid", "genbankid", "comments", "original_description", "submitter"):
				continue
			oldValue = getattr(thisTrait, field)
			if not oldValue:
				oldValue = ''
			oldValue = str(oldValue)
			modifiedValue = self.formdata.getvalue(field)
			if not modifiedValue:
				modifiedValue = ""
			modifiedValue.strip()
			oldValue.strip()
			if oldValue == modifiedValue:
				form.append(HT.Input(type="hidden",name=field,value=oldValue))
				continue
				
			oldValue = HT.Paragraph(oldValue, Class="cr")
			warning = ''
			if field == 'PubMed_ID':
				if modifiedValue != "":
					try:
						modifiedValue = int(modifiedValue)
					except:
						continue
					
				#whether new PMID already exists
				newPMIDExist = None
				if modifiedValue:
					self.cursor.execute("SelecT Id from Publication where PubMed_ID = %d" % modifiedValue)
					results = self.cursor.fetchall()
					if results:
						newPMIDExist = results[0][0]
				if newPMIDExist:
					warning = HT.Paragraph(Class="fs11 cr")
					warning.append('This new PubMed_ID already exists in our database. If you still want to change to this very PubMed_ID, the publication information (title, author, journal, etc.) will be replaced by those linked to this new PubMed_ID. That means, all the fields below (if any, except phenotype info and trait value) will be ignored.')

			infoChanges.append(field)
			inputBox = HT.Textarea(name=field, cols=50, rows=3,text=modifiedValue, onChange = "Javascript:this.form.curStatus.value='updateCheck';")
			recordInfoTable.append(
				HT.TR(HT.TD("%s :" % webqtlUtil.formatField(field), Class="fs12 fwb ff1", colspan = 3, valign="top")), 
				HT.TR(HT.TD(oldValue, valign="top"),HT.TD(width=20),HT.TD( inputBox, warning)))

		#XZ: homologeneid is not in thisTrait.db.disfield
		if thisTrait.db.type == "ProbeSet":
			field = 'homologeneid'
			oldValue = getattr(thisTrait, field)
                        if not oldValue:
                                oldValue = ''
                        oldValue = str(oldValue)
                        modifiedValue = self.formdata.getvalue(field)
                        if not modifiedValue:
                                modifiedValue = ""
                        modifiedValue.strip()
                        oldValue.strip()

                        if oldValue == modifiedValue:
                                form.append(HT.Input(type="hidden",name=field,value=oldValue))
                        else:
				oldValue = HT.Paragraph(oldValue, Class="cr")
				warning = ''
				infoChanges.append(field)
				inputBox = HT.Textarea(name=field, cols=50, rows=3,text=modifiedValue, onChange = "Javascript:this.form.curStatus.value='updateCheck';")
	                        recordInfoTable.append(
        			                        HT.TR(HT.TD("%s :" % webqtlUtil.formatField(field), Class="fs12 fwb ff1", colspan = 3, valign="top")),
                                			HT.TR(HT.TD(oldValue, valign="top"),HT.TD(width=20),HT.TD( inputBox, warning)))
				

		if infoChanges == []:
			recordInfoTable = ""
			recordInfoChange = HT.Blockquote('No change has been made.')
		else:
			hddn['modifiedField'] = string.join(infoChanges, '::')
			recordInfoChange = ''
			
		recordDataChange = HT.Blockquote('Trait data updating is disabled')
		recordDataTable = ""
		
		modifiedVals = []
		modifiedVars = []
		modifiedNps = []
		numDataChanges = 0
		if thisTrait.db.type == 'Publish':
			thisTrait.retrieveData()
			recordDataTable = HT.TableLite(border=0, width = "90%",cellspacing=2, cellpadding=2)
			for i, strainName in enumerate(fd.strainlist):
				if thisTrait.data.has_key(strainName):
					tdata = thisTrait.data[strainName]
					traitVal, traitVar, traitNP = tdata.val, tdata.var, tdata.N
				else:
					traitVal, traitVar, traitNP = None, None, None
				
				if traitVal != None:	
					traitVal = "%2.3f" % traitVal
				else:
					traitVal = 'x'
				if traitVar != None:	
					traitVar = "%2.3f" % traitVar
				else:
					traitVar = 'x'
				if traitNP != None:	
					traitNP = "%d" % traitNP
				else:
					traitNP = 'x'
					
				try:	
					modifiedVal =  "%2.3f" % fd.allTraitData[strainName].val
				except:
					modifiedVal = 'x'
				try:	
					modifiedVar = "%2.3f" % fd.allTraitData[strainName].var
				except:
					modifiedVar = 'x'
				try:	
					modifiedNp = "%d" % fd.allTraitData[strainName].N
				except:
					modifiedNp = 'x'
				
				if modifiedVal != traitVal:
					recordDataTable.append(HT.TR(HT.TD(HT.Paragraph(strainName + " Value")),
						HT.TD(HT.Paragraph(traitVal, Class="cr")), 
						HT.TD(HT.Input(name=strainName, size=8, maxlength=8, value=modifiedVal, onChange = "Javascript:this.form.curStatus.value='updateCheck';"))))
					numDataChanges += 1
					modifiedVals.append(modifiedVal)
				else:
					form.append(HT.Input(type="hidden",name=strainName,value=traitVal))
					modifiedVals.append(traitVal)
					
				if modifiedVar != traitVar:
					recordDataTable.append(HT.TR(HT.TD(HT.Paragraph(strainName + " SE")),
						HT.TD(HT.Paragraph(traitVar, Class="cr")), 
						HT.TD(HT.Input(name='V'+strainName, size=8, maxlength=8, value=modifiedVar, onChange = "Javascript:this.form.curStatus.value='updateCheck';"))))
					numDataChanges += 1
					modifiedVars.append(modifiedVar)
				else:
					form.append(HT.Input(type="hidden",name='V'+strainName,value=traitVar))
					modifiedVars.append(traitVar)
					
				if modifiedNp != traitNP:
					recordDataTable.append(HT.TR(HT.TD(HT.Paragraph(strainName + " N Per Strain")),
						HT.TD(HT.Paragraph(traitNP, Class="cr")), 
						HT.TD(HT.Input(name='N'+strainName, size=8, maxlength=8, value=modifiedNp, onChange = "Javascript:this.form.curStatus.value='updateCheck';"))))
					numDataChanges += 1
					modifiedNps.append(modifiedNp)
				else:
					form.append(HT.Input(type="hidden",name='N'+strainName,value=traitNP))
					modifiedNps.append(traitNP)
					
					
			if numDataChanges == 0:
				recordDataChange = HT.Blockquote('No change has been made.')
				recordDataTable = ""
			else:
				hddn['modifiedDataField'] = 1
				recordDataChange = ""
				
		#if numDataChanges:
		#	hddn['val'] = string.join(modifiedVals, ',')
		#	hddn['var'] = string.join(modifiedVars, ',')
		#	hddn['np'] = string.join(modifiedNps, ',')
			
		for key in hddn.keys():
			form.append(HT.Input(name=key, value=hddn[key], type='hidden'))

		#############################
		TD_LR = HT.TD(valign="top",colspan=2,bgcolor="#eeeeee", height=200)
		
		mainTitle = HT.Paragraph("Update Info and Data", Class="title")
		
		title1 = HT.Paragraph("Trait Information:", Class="subtitle")

		title2 = HT.Paragraph("Trait Data:", Class="subtitle")
		
		if numDataChanges or infoChanges:
			recordChange = HT.Blockquote('The table below lists all the changes made. The texts in red are the original information stored on the server, the texts to the right are the modified version. ')
			updateButton = HT.Input(type='submit',name='submit', value='Update Data',Class="button")
			resetButton = HT.Input(type='reset',Class="button")
			form.append(title1, HT.Center(updateButton,resetButton), recordInfoChange, recordInfoTable,title2, recordDataChange, HT.Center(recordDataTable,HT.P(),updateButton,resetButton),HT.P())
			TD_LR.append(mainTitle, recordChange, HT.Blockquote(form))
		else:
			recordInfoChange = HT.Blockquote("No change has been made")
			TD_LR.append(mainTitle, recordInfoChange)
			
		self.dict['body'] = TD_LR
		#self.dict['js1'] = webqtlConfig.resetFieldScript
		return