Re: [Zope] Zope/Plone Form Question

2006-11-29 Thread Andreas Jung
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1



- --On 29. November 2006 09:40:40 -0500 "Christopher A. Nethery" 
<[EMAIL PROTECTED]> wrote:

> 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
>

Upon successful validation you redirect to a script (see CMFFormController 
docs) that calls something like that:



pdffile = getPDFData()

R = context.REQUEST.RESPONSE

R.setHeader('content-type', 'appliction/pdf')  # check that
R.setHeader('content-length', str(len(pdffile))
R.write(pdffile)

Depending on your app you can also use a file_stream_iterator() instead of 
the last write() call. Google for details.

- -aj
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFFbefwCJIWIbr9KYwRAslzAJ9mcUb09x7aKibuZkMpMZfwEUXweACg3DBt
WCc4kyXEY3+e4M+ntD/YxA0=
=iSox
-END PGP SIGNATURE-

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Zope/Plone Form Question

2006-11-29 Thread Christopher A. Nethery
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)

--

 



  

 

The title

 

  

 

  

 

  Portfolio Manager
Assignment

 



 

  

  Enter query parameters:

 



 

Portfolio

  



 

Group Name

  



 

Run Date (mmddyy)

  



 

From Date (mmddyy)

  



 

To Date (mmddyy)

  



 



  

  



 





  



 

 

---

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

 

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )