passing values tp python script from a zope page template through a link
I wrote a xmlrpclib server and client file but this is the first time I am trying to pass a value from my zope page template to my python script that executes a server sub routine. Also, the python function should be triggered by a link. This is what I have so far: python script: def deleteHost(): server=xmlrpclib.Server("http://localhost:8080/RPC2") delete = server.sample.DeleteHost() return server script: sub DeleteHost(){ my ($pcName) = @_; my ($name) = "'" . $pcName . "'"; my $delete = "Delete from Host where SystemNetName = $name"; print "$delete\n"; if ($db->Sql($delete)){ print "Error on SQl DELETE\n"; Win32::ODBC::DumpError(); } else { print "delete successful\n"; } } I am not sure how to pass the value pcName from the zope page template. Any suggestions? -Laura
Are you thinking of something like this? <a tal:attributes="href string:yourPyScript?pcName=${pcName}"> -- David On Aug 27, 2004, at 1:37 PM, Laura McCord wrote:
Also, the python function should be triggered by a link. This is what I have so far:
...
I am not sure how to pass the value pcName from the zope page template.
On Fri, Aug 27, 2004 at 03:37:55PM -0500, Laura McCord wrote:
I wrote a xmlrpclib server and client file but this is the first time I am trying to pass a value from my zope page template to my python script that executes a server sub routine.
Also, the python function should be triggered by a link. This is what I have so far:
I think I can get you part way there. Create a <form> in your ZPT. In the form, put <input>, <select>, etc elements that have names corresponding to the parameter names of your Python Script. (Make them hidden if you do not want them visible in the page.) On the <form> element, give the action attribute the name of your Python Script. For example, suppose your Python Script is named "infoAction_py" and it has a parameter list: "user_name, user_email". You could use the following form: <form action="infoAction_py"> <p>Name: <input type="text" name="user_name"/></p> <p>Email: <input type="text" name="user_email"/></p> <p><input type="submit" name="submit" value=" Submit "></p> </form> When you submit the page containing this form, Zope will call your script (infoAction_py), provided it is in the same folder as your ZPT/form. Does that help? Dave [snip] -- Dave Kuhlman http://www.rexx.com/~dkuhlman
participants (3)
-
Dave Kuhlman -
David Siedband -
Laura McCord