感谢您的审核 - 我的目标是让Web表单修改python变量并返回构建输出。 python脚本遍历一个字典,只返回一个输出,如果' x'变量== 1.这个' x'变量是我需要修改的。下面,您将看到dict,变量和脚本,遵循Web表单。
SAMPLE_AUDIT_1 = {}
SAMPLE_AUDIT_1['VERSION'] = 'ORACLE 2012'
SAMPLE_AUDIT_1['LINK'] = 'LINK TO THE AUDIT CONTENT'
SAMPLE_AUDIT_1['Software Version'] = 0
SAMPLE_AUDIT_1['Server OS, Memory, CPU'] = 0
SAMPLE_AUDIT_1['DBMS Version'] = 0
SAMPLE_AUDIT_1['DBMS Statistics'] = 0
SAMPLE_AUDIT_1['DBMS Parameters'] = 0
SAMPLE_AUDIT_1['DBMS Data File Growth'] = 0
SAMPLE_AUDIT_1['Database Disk Structure'] = 0
SAMPLE_AUDIT_1['Long Running SQL'] = 0
SAMPLE_AUDIT_1['Security Data Growth Range'] = 0
SAMPLE_AUDIT_1['Extraneous entries in System Tables'] = 0
SAMPLE_AUDIT_1['Feed Error Orphans'] = 1
SAMPLE_AUDIT_1['Position Detail Orphans'] = 1
SAMPLE_AUDIT_1['Data Retention Policy'] = 1
SAMPLE_AUDIT_1['Securities Added Daily'] = 0
SAMPLE_AUDIT_1['Security Master Load'] = 0
SAMPLE_AUDIT_1['SRM Purge'] = 0
SAMPLE_AUDIT_1['Best Pricing Purge'] = 0
SAMPLE_AUDIT_1['Partitioning'] = 1
SAMPLE_AUDIT_1['DBMS Data/Log File Utilize Shared Disk'] = 0
SAMPLE_AUDIT_1['DBMS Failover'] = 0
SAMPLE_AUDIT_1['DBMS Client Version'] = 0
SAMPLE_AUDIT_1['Star Engine IP Configuration'] = 0
SAMPLE_AUDIT_1['Engine Count/Configuration'] = 1
SAMPLE_AUDIT_1['Engine Logging Interval'] = 1
SAMPLE_AUDIT_1['Engine Port Configuration'] = 0
SAMPLE_AUDIT_1['Server Logging'] = 1
SAMPLE_AUDIT_1['Engine Log Configuration'] = 0
SAMPLE_AUDIT_1['Engine Load Balancer Interval'] = 0
SAMPLE_AUDIT_1['Engines Restarted Weekly'] = 0
SAMPLE_AUDIT_1['Designated Master'] = 0
SAMPLE_AUDIT_1['Cluster Managers Identical'] = 0
SAMPLE_AUDIT_1['Uploader Shared Disk Space'] = 0
SAMPLE_AUDIT_1['Custom Archive Rule Shared Disk Space'] = 0
SAMPLE_AUDIT_1['Event Concurrency'] = 1
SAMPLE_AUDIT_1['Homogenous Engine Configuration'] = 0
SAMPLE_AUDIT_1['Log Levels'] = 1
SAMPLE_AUDIT_1['Scheduler Purging'] = 0
SAMPLE_AUDIT_1['Email Notification Basic Configuration'] = 0
SAMPLE_AUDIT_1['Web Load Balancer Configuration'] = 0
SAMPLE_AUDIT_1['Load Balancer Customizations'] = 0
SAMPLE_AUDIT_1['Portal Shared Disk Space'] = 0
SAMPLE_AUDIT_1['Message Center Shared Disk Space'] = 0
SAMPLE_AUDIT_1['Message Center ID\'S'] = 0
SAMPLE_AUDIT_1['Schedule Service Config'] = 1
SAMPLE_AUDIT_1['ePace is a client of Clustered App Servers'] = 1
SAMPLE_AUDIT_1['Portal is a client of Clustered App Servers'] = 0
SAMPLE_AUDIT_1['client of Clustered Engines'] = 1
SAMPLE_AUDIT_1['client of Clustered Report Export Services'] = 1
SAMPLE_AUDIT_1['WebSync Configured'] = 0
SAMPLE_AUDIT_1['Web Server Load Balancing Configured'] = 0
SAMPLE_AUDIT_1['Shared Disk Dynamic Folder'] = 0
x = 'Feed Error Orphans'
for k, v in SAMPLE_AUDIT_1.iteritems():
if k == x and v == 1:
print 'SAMPLE_AUDIT_1', SAMPLE_AUDIT_1['VERSION'], SAMPLE_AUDIT_1['LINK']
我的目标是从表单下拉列表中选择一个dict键并使用jquery提交。从那里我需要修改' x'变量然后从python脚本返回输出。表格如下:
<section id="forms">
<div class="row">
<div class="span10 offset1">
<form class="form-horizontal well">
<fieldset>
<legend>Select Audit Point</legend>
<div class="control-group">
<label class="control-label" for="select01">Select Audit Point</label>
<div class="controls">
<select id="select03">
<option value="all">Software Version</option>
<option value="all">Server OS, Memory, CPU</option>
<option value="all">High Availability</option>
<option value="db">DBMS Version</option>
<option value="db">DBMS Statistics</option>
<option value="db">DBMS Parameters</option>
<option value="db">DBMS Data File Growth</option>
<option value="db">Database Disk Structure</option>
<option value="db">Long Running SQL</option>
<option value="db">Security Data Growth Range</option>
<option value="db">Extraneous entries in System Tables</option>
<option value="db">Feed Error Orphans</option>
<option value="db">Position Detail Orphans</option>
<option value="db">Data Retention Policy</option>
<option value="db">Securities Added Daily</option>
<option value="db">Security Master Load</option>
<option value="db">SRM Purge</option>
<option value="db">Best Pricing Purge</option>
<option value="db">Partitioning</option>
<option value="db">DBMS Data/Log File Utilize Shared Disk</option>
<option value="db">DBMS Failover</option>
<option value="app">DBMS Client Version</option>
<option value="app">Star Engine IP Configuration</option>
<option value="app">Engine Count/Configuration</option>
<option value="app">Engine Logging Interval</option>
<option value="app">Engine Port Configuration</option>
<option value="app">Server Logging</option>
<option value="app">Engine Log Configuration</option>
<option value="app">Engine Load Balancer Interval</option>
<option value="app">Engines Restarted Weekly</option>
<option value="app">Designated Master</option>
<option value="app">Cluster Managers Identical</option>
<option value="app">Uploader Shared Disk Space</option>
<option value="app">Custom Archive Rule Shared Disk Space</option>
<option value="app">App Server Clustering</option>
<option value="app">Event Concurrency</option>
<option value="web">Homogenous Engine Configuration</option>
<option value="web">Log Levels</option>
<option value="web">Scheduler Purging</option>
<option value="web">Web Server Services Restarted Weekly</option>
<option value="web">Email Notification Basic Configuration</option>
<option value="web">Web Load Balancer Configuration</option>
<option value="web">Load Balancer Customizations</option>
<option value="web">Portal Shared Disk Space</option>
<option value="web">Message Center Shared Disk Space</option>
<option value="web">Message Center ID'S</option>
<option value="web">Schedule Service Config</option>
<option value="web">client of Clustered App Servers</option>
<option value="web">client of Clustered App Servers</option>
<option value="web">client of Clustered Load Balancers</option>
<option value="web">client of Clustered Engines</option>
<option value="web">client of Clustered Report Export Services</option>
<option value="web">WebSync Configured</option>
<option value="web">Web Server Load Balancing Configured</option>
<option value="web">Shared Disk Dynamic Folder</option>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn">Cancel</button>
</div>
</fieldset>
</form>
</div>
</div>
我已经通过cgi研究了原始输入,但我仍然不清楚这个问题。理想情况下,我想用jquery提交值,修改python变量,运行脚本并使用jquery返回输出。我知道Django的知识在这种情况下会非常有用,但我仍然是新手。
非常感谢你的帮助。非常感谢。
答案 0 :(得分:0)
为什么要为许多选项提交相同的值?如果您省略value
- 标记,您的脚本将在下拉列表中选择字符串。您所需要的只是一个try-except
- 构造。