[Zope] Zope/Plone Form Question
Christopher A. Nethery
can at wasmerschroeder.com
Wed Nov 29 09:40:40 EST 2006
Hello all,
I have created:
- a Controller Page Template
- a Controller Validator script and,
- a Controller Python script
I am trying to create a form whose values are used by a script to:
- query a separate reporting system
- generate a .pdf document with the resulting report and,
- post the contents of the .pdf to a results page
I cannot seem to figure out how to generate the results page. Could
anyone shed some light on this?
You will note some poor python code practices (especially in the
validator script) which I apologize for (too hurried), so please be
forgiving...
Thanking you in advance,
Chris Nethery
My code is below. So far, I have the following:
------------------------------
PMA (Controller Page Template)
------------------------------
<html>
<head>
<title tal:content="template/title">The title</title>
</head>
<body tal:define="errors options/state/getErrors">
<h2 tal:content="template/title_or_id">Portfolio Manager
Assignment</h2>
<form method="POST" tal:attributes="action
string:${here/absolute_url}/${template/id};">
<p class="error_message" tal:define="err errors/n|nothing"
tal:condition="err"><b tal:content="err" /></p>
<p>Enter query parameters:</p><br>
<table>
<tr><th>Portfolio</th>
<td><input name="portfolio" size="10" value=""></td>
</tr>
<tr><th>Group Name</th>
<td><input name="group_name" size="10" value=""></td>
</tr>
<tr><th>Run Date (mmddyy)</th>
<td><input name="run_date" size="10" value=""></td>
</tr>
<tr><th>From Date (mmddyy)</th>
<td><input name="from_date" size="10" value=""></td>
</tr>
<tr><th>To Date (mmddyy)</th>
<td><input name="to_date" size="10" value=""></td>
</tr>
<tr>
<td colspan=2 align=center><input type="SUBMIT"
name="form.button.submit" value="OK"></td>
<input type="hidden" name="form.submitted" value="1" />
</tr>
</table>
</form>
</body>
</html>
-------------------------------------------
PMAValidators (Controller Validator Script)
-------------------------------------------
portfolio = context.REQUEST.get('portfolio', None)
run_date = context.REQUEST.get('run_date', None)
from_date = context.REQUEST.get('from_date', None)
to_date = context.REQUEST.get('to_date', None)
if not portfolio:
state.setError('portfolio', 'Please enter a portfolio')
if state.getErrors():
state.setStatus('failure')
return state.set(portal_status_message='Please correct the errors
shown')
if not run_date:
state.setError('run_date', 'Please enter a run date')
if state.getErrors():
state.setStatus('failure')
return state.set(portal_status_message='Please correct the errors
shown')
if not from_date:
state.setError('from_date', 'Please enter a "from" date')
if state.getErrors():
state.setStatus('failure')
return state.set(portal_status_message='Please correct the errors
shown')
if not to_date:
state.setError('to_date', 'Please enter a "to" date')
if state.getErrors():
state.setStatus('failure')
return state.set(portal_status_message='Please correct the errors
shown')
return state
------------------------------------
PMAScript (Controller Python script)
------------------------------------
import os
import string
import sys
# Get value(s) from the REQUEST
portfolio = context.REQUEST.get('portfolio')
run_date = context.REQUEST.get('run_date')
from_date = context.REQUEST.get('from_date')
to_date = context.REQUEST.get('to_date')
#Create .pdf
y = stuff
x = os.system(y)
### What now? ###
### state.setNextAction ? ###
return state
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20061129/30e66e19/attachment.htm
More information about the Zope
mailing list