1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# Copyright (C) University of Tennessee Health Science Center, Memphis, TN.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# This program is available from Source Forge: at GeneNetwork Project
# (sourceforge.net/projects/genenetwork/).
#
# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
#
#
#
# This module is used by GeneNetwork project (www.genenetwork.org)
#
# Created by GeneNetwork Core Team 2010/08/10
#
# Last updated by GeneNetwork Core Team 2010/10/20
import sys
from htmlgen import HTMLgen2 as HT
from base.templatePage import templatePage
from base import webqtlConfig
class UpdateCommentPage(templatePage):
def __init__(self,fd):
sys.stderr = sys.stdout
templatePage.__init__(self, fd)
body = HT.SimpleDocument()
if not self.updMysql():
#{
print 'Content-type: text/html\n'
print 'Can not update the comment of %s' %(TableName)
return
#}
Cursor_Comment=self.cursor
TableName = fd.formdata.getfirst('TableName')
Comment = fd.formdata.getfirst('Comment')
########################
#update table's comment#
########################
Cursor_Comment.execute('select * from TableComments where TableName=%s', (TableName))
if Cursor_Comment.fetchall():
Cursor_Comment.execute('update TableComments set Comment=%s where TableName=%s', (Comment, TableName))
else:
Cursor_Comment.execute('insert into TableComments values(%s,%s)', (TableName, Comment))
#################################
#update table fields' annotation#
#################################
try:
#{
Cursor_Comment.execute('desc %s' %(TableName))
TableDesc = Cursor_Comment.fetchall()
for i in range(0, len(TableDesc)):
#{
TableField = TableName+'.'+str(TableDesc[i][0])
TableFieldForeignKey = TableField+'ForeignKey'
TableFieldAnnotation = TableField+'Annotation'
ForeignKey = fd.formdata.getfirst(TableFieldForeignKey)
if ForeignKey == 'None':
ForeignKey=''
Annotation = fd.formdata.getfirst(TableFieldAnnotation)
if Annotation == 'None':
Annotation=' '
Cursor_Comment.execute('select * from TableFieldAnnotation where TableField=%s', (TableField))
if Cursor_Comment.fetchall():
Cursor_Comment.execute('update TableFieldAnnotation set Foreign_Key=%s, Annotation=%s where TableField=%s', (ForeignKey, Annotation, TableField))
else:
Cursor_Comment.execute('insert into TableFieldAnnotation values(%s,%s,%s)', (TableField, ForeignKey, Annotation))
#}
#}
except:
pass
HtmlHref = HT.Href(webqtlConfig.CGIDIR+'main.py?FormID=schemaShowPage#%s' %(TableName), 'table')
HtmlBlock = HT.Blockquote();
HtmlBlock.append('This ')
HtmlBlock.append(HtmlHref)
HtmlBlock.append('\'s comment has been succesfully updated')
body.append(HtmlBlock)
self.dict['body'] = body
|