Re: [Zope] Python Scripts and HTML Forms

2006-08-18 Thread Muk Yan
Hi Jonathan,Thanks a lot, it works today, but it was acting up a bit yesterday. I really appreciate it, maybe I just needed to completely get rid of the browser cache.Peace and thanks again,Muk
On 8/17/06, Jonathan [EMAIL PROTECTED] wrote:







If you have a line like

input type=text name=first_name 
value=default value

in your html file then if you try the following in 
your script file

print REQUEST['first_name'] 
return printed

you should see default value printed 
out

you can try:

print REQUEST

to see the entire contents of REQUEST (very 
informative)

Note: if you do not have a default value in your 
input statement and you do not enter anything in the input field when 
the form is displayed, then when the form is submitted REQUEST will not contain 
an entry for the corresponding form field (an entry is made in REQUEST only when 
data is entered in the form field)


Jonathan



  - Original Message - 
  
From: 
  Muk Yan 
  To: 
Jonathan 
  Cc: 
zope@zope.org 
  Sent: Thursday, August 17, 2006 4:40 
  PM
  Subject: Re: [Zope] Python Scripts and 
  HTML Forms
  Hey All,Sorry about that, what I meant is that I get a 
  KeyError. It says that the first_name in REQUEST['first_name'] is not found, 
  when I try to set the variable in line in the script where fname = 
  REQUEST['first_name'].Thanks in 
  advance.Cheers,Muk
  On 8/17/06, Jonathan  
  [EMAIL PROTECTED] wrote:
  


What does it doesn't seem to work mean? 
Error messages/traceback? What does your form  script contain? 
More info on the problem is definitely required!




Jonathan



- 
Original Message - 

From: 
Muk Yan 

To: 
Jonathan ; 
zope@zope.org 
Sent: 
Thursday, August 17, 2006 4:20 PM
Subject: 
Re: [Zope] Python Scripts and HTML Forms
Hey Jonathan, All,Thanks I tried your solution, but 
it doesn't seem to work. Can anybody shed some more light on this 
situation, since what Jonathan provides is exactly what I want to do, but 
it's not working.Am I forgetting to put parameteres or some other 
newbie mistake like that?Thanks in advance and thanks again 
Jonathan.-Muk
On 8/17/06, Jonathan [EMAIL PROTECTED] wrote: 


  
  
  Form variables are stored in REQUEST. In a 
  python script you gain access to REQUEST by:
  
  REQUEST= 
  container.REQUEST
  you can then access the form variables 
  by:
  
  fname = REQUEST['first_name']
  
  
  you can check for the presence of a form 
  variable by
  
  if 
  REQUEST.has_key('first_name'):
  
  or
  
  if REQUEST.get('first_name', 
  None):
  
  
  hth
  
  Jonathan
  
  
  
  - 
  Original Message - 
  
From: 
  Muk Yan 
  To: 
  zope@zope.org 
  Sent: 
  Thursday, August 17, 2006 2:57 PM
  Subject: 
  [Zope] Python Scripts and HTML Forms
  Dear Trusted Zope Zealots,This subject was a bit 
  too broad to do a google search on, because I've tried and the lack of 
  relevancy was astounding.I've probably been committing a cardinal 
  sin in DTML, but I couldn't figure any other work around. I have 
  an HTML form in a DTML Document say:form 
  action="" method=postName:input type=text 
  name:first_name/form I want to use 
  first_name in a python script, but what I've been doing is setting it in 
  the process_this_form, which is a DTML method:DTML Method, 
  process_this_form:dtml-call REQUEST.SESSION.set ('firstName', 
  first_name)dtml-call 
  this_is_a_python_script()and in the Python Script, 
  this_is_a_python_scriptI use 
  REQUEST.SESSION.get('firstName')What my question is, is there 
  anyway to directly access first_name from the form in the python script 
  without having to have to call the dtml-call  
  REQUEST.SESSION.set('firstName', first_name) and then 
  REQUEST.SESSION.get('firstName') in the python script. Sort of a 
  sophomoric question, but any help would be appreciated. Thanks in 
  advance.-Muk
  
  
  

  ___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 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] Python Scripts and HTML Forms

2006-08-17 Thread Muk Yan
Dear Trusted Zope Zealots,This subject was a bit too broad to do a google search on, because I've tried and the lack of relevancy was astounding.I've probably been committing a cardinal sin in DTML, but I couldn't figure any other work around.
I have an HTML form in a DTML Document say:form action="" method=postName:input type=text name:first_name/form
I want to use first_name in a python script, but what I've been doing is setting it in the process_this_form, which is a DTML method:DTML Method, process_this_form:dtml-call REQUEST.SESSION.set
('firstName', first_name)dtml-call this_is_a_python_script()and in the Python Script, this_is_a_python_scriptI use REQUEST.SESSION.get('firstName')What my question is, is there anyway to directly access first_name from the form in the python script without having to have to call the dtml-call 
REQUEST.SESSION.set('firstName', first_name) and then REQUEST.SESSION.get('firstName') in the python script. Sort of a sophomoric question, but any help would be appreciated. Thanks in advance.-Muk
___
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 )


Re: [Zope] Python Scripts and HTML Forms

2006-08-17 Thread Muk Yan
Hey Jonathan, All,

Thanks I tried your solution, but it doesn't seem to work. Can anybody
shed some more light on this situation, since what Jonathan provides is
exactly what I want to do, but it's not working.

Am I forgetting to put parameteres or some other newbie mistake like that?

Thanks in advance and thanks again Jonathan.

-MukOn 8/17/06, Jonathan [EMAIL PROTECTED] wrote:







Form variables are stored in REQUEST. In a python 
script you gain access to REQUEST by:

REQUEST= container.REQUEST
you can then access the form variables 
by:

fname = REQUEST['first_name']


you can check for the presence of a form variable 
by

if 
REQUEST.has_key('first_name'):

or

if REQUEST.get('first_name', 
None):


hth

Jonathan


  - Original Message - 
  
From: 
  Muk Yan 
  To: 
zope@zope.org 
  Sent: Thursday, August 17, 2006 2:57 
  PM
  Subject: [Zope] Python Scripts and HTML 
  Forms
  Dear Trusted Zope Zealots,This subject was a bit too 
  broad to do a google search on, because I've tried and the lack of relevancy 
  was astounding.I've probably been committing a cardinal sin in DTML, 
  but I couldn't figure any other work around. I have an HTML form in a 
  DTML Document say:form action="" 
  method=postName:input type=text 
  name:first_name/form I want to use first_name 
  in a python script, but what I've been doing is setting it in the 
  process_this_form, which is a DTML method:DTML Method, 
  process_this_form:dtml-call REQUEST.SESSION.set ('firstName', 
  first_name)dtml-call this_is_a_python_script()and in 
  the Python Script, this_is_a_python_scriptI use 
  REQUEST.SESSION.get('firstName')What my question is, is there anyway 
  to directly access first_name from the form in the python script without 
  having to have to call the dtml-call  REQUEST.SESSION.set('firstName', 
  first_name) and then REQUEST.SESSION.get('firstName') in the python 
  script. Sort of a sophomoric question, but any help would be 
  appreciated. Thanks in advance.-Muk
  
  

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


Re: [Zope] Python Scripts and HTML Forms

2006-08-17 Thread Muk Yan
Hey All,Sorry about that, what I meant is that I get a KeyError. It says that the first_name in REQUEST['first_name'] is not found, when I try to set the variable in line in the script where 
fname = REQUEST['first_name'].Thanks in advance.Cheers,MukOn 8/17/06, Jonathan 
[EMAIL PROTECTED] wrote:






What does it doesn't seem to work mean? 
Error messages/traceback? What does your form  script contain? More 
info on the problem is definitely required!



Jonathan

  - Original Message - 
  
From: 
  Muk Yan 
  To: 
Jonathan ; zope@zope.org 
  Sent: Thursday, August 17, 2006 4:20 
  PM
  Subject: Re: [Zope] Python Scripts and 
  HTML Forms
  Hey Jonathan, All,Thanks I tried your solution, but it 
  doesn't seem to work. Can anybody shed some more light on this 
  situation, since what Jonathan provides is exactly what I want to do, but it's 
  not working.Am I forgetting to put parameteres or some other newbie 
  mistake like that?Thanks in advance and thanks again 
  Jonathan.-Muk
  On 8/17/06, Jonathan [EMAIL PROTECTED] wrote:

  


Form variables are stored in REQUEST. In a 
python script you gain access to REQUEST by:

REQUEST= 
container.REQUEST
you can then access the form variables 
by:

fname = REQUEST['first_name']


you can check for the presence of a form 
variable by

if 
REQUEST.has_key('first_name'):

or

if REQUEST.get('first_name', 
None):


hth

Jonathan



- 
Original Message - 

From: 
Muk Yan 
To: 
zope@zope.org 
Sent: 
Thursday, August 17, 2006 2:57 PM
Subject: 
[Zope] Python Scripts and HTML Forms
Dear Trusted Zope Zealots,This subject was a bit too 
broad to do a google search on, because I've tried and the lack of relevancy 
was astounding.I've probably been committing a cardinal sin in DTML, 
but I couldn't figure any other work around. I have an HTML form in 
a DTML Document say:form action="" 
method=postName:input type=text 
name:first_name/form I want to use 
first_name in a python script, but what I've been doing is setting it in 
the process_this_form, which is a DTML method:DTML Method, 
process_this_form:dtml-call REQUEST.SESSION.set ('firstName', 
first_name)dtml-call this_is_a_python_script()and 
in the Python Script, this_is_a_python_scriptI use 
REQUEST.SESSION.get('firstName')What my question is, is there anyway 
to directly access first_name from the form in the python script without 
having to have to call the dtml-call  REQUEST.SESSION.set('firstName', 
first_name) and then REQUEST.SESSION.get('firstName') in the python 
script. Sort of a sophomoric question, but any help would be 
appreciated. Thanks in advance.-Muk




___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 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] Providing Arguments to ZSQL Methods that Insert and Update in Python

2006-08-06 Thread Muk Yan
Dear Zenith of Zope Knowledge,Thanks for all the help from before it is truly appreciated.I know that it's possible to provide arguments when selecing in a ZSQL Method, but is it possible to provide arguments to UPDATE and INSERT.
I'll use an example that I found from a previous entry in the Zope mailing list.The ZSQL method looks like this:Arguments: emp_id first last salary
UPDATE personSET person_first_name = first,person_last_name = last,person_salary = salaryWHERE person_emp_id = emp_idand the call in the Script(Python) would be:(context.aq_parent).updates.update_person(empid=someval1, first=someval2,
last=someval3, salary=someval4)I'm having trouble correlating the Python variables with the ones in the ZSQL method. I know how to pass variables from forms in DTML documents via dtml-sqlvar emp_id type=string. Any help would be appreciated. Thanks in advance and have a great weekend!
Take care,Muk Yan
___
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 )


Re: [Zope] Providing Arguments to ZSQL Methods that Insert and Update in Python

2006-08-06 Thread Muk Yan
Thanks Andreas, sorry about the confusion.What I want to do is call the ZSQL Method from a Python script instead of from a DTML Document or Method. I want to know if there's a way to provide arguments from the Python Script
to ZSQL Methods with Updates and Inserts.This is just a toy problem:Arguments: emp_id first last salary
UPDATE personSET person_first_name = first,person_last_name = last,person_salary = salaryWHERE person_emp_id = emp_id(context.aq_parent).updates.update_person(empid=someval1, first=someval2,
last=someval3, salary=someval4)I want to avoid using dtml-sqlvar emp_id type=string.Thanks again.Peace and take care,Muk


___
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] Filling Out a PDF

2006-08-03 Thread Muk Yan
Dear Knowledgeable Zope Zealots,Thanks for pointing me in the right direction last time, I just didn't know that I should have searched for zsql instead of sql.I've racked my brain and searched the great vastness to no avail. I have some PDF forms that I've converted to HTML in order for people to fill them out and then print them.
I was wondering was there any way to edit the PDF directly or convert the PDF to another format and enter in the information that the user has entered? Of course any help would be appreciated. I've already converted the forms to PDF, but it of course doesn't look *exactly* like the PDF which is what I would prefer. Do you think maybe remaking the PDF's into ZPDF would be a good path to follow?
Maybe convert it to an FDF and somehow get the infor from the webform into it and then spit back out a completed PDF?Thanks again and take care all,Muk
___
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] MySQL queries in Python

2006-08-01 Thread Muk Yan
Dear Coveted Braintrust,I was wondering if anyone had any experience with MySQL queries in Python in Zope:import MySQLdbimport stringrequest = container.REQUESTsession = request.SESSION
result = (context.aq_parent).selects.select_from_table()print resultreturn printedWHERE select.select_from_table() IS:SELECT nameFROM personWHERE ID = dtml-var REQUEST.SESSION.get
('person_id')I know the MySQL query works, but I get garbage results from the python script (Shared.DC.ZRDB.Results.Results instance at 0x132a5c88). All I want is to contain the results of the SQL query in a list or container.
Thanks and take care,Muk Yan
___
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] Using the DTML REQUEST Object

2006-07-18 Thread Muk Yan

Dear Exalted Sirs and Madams,

I'm a Zope newbie, so be gentle.

I'm using DTML on Zope (yes I know Plone and Tal is now the norm) and
I was wondering if regularly using the REQUEST(set and get) object is
bad practice.

I'm mostly a C++ programmer and I know of the horrors of global
variables, but I was wondering if there was any way to pass
information from DTML Documents to DTML Methods and vice versa (and
maybe from DTML Methods to DTML Methods) without using the REQUEST
object.

Thanks and take care,
Muk Yan
___
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 )