RE: [Zope] using xml-rpc with javascript to access zope
Hi Chris,
If not, I'd suggest trying to implement this in very, very small pieces. e.g. make a JavaScript function that does something simple like, >calls an XML-RPC method that returns "1+1" and then displays the result 2 within the DOM using JavaScript, then build up from there incrementally.
Yes, this is my biggest problem, how do I call a simple xml-rpc method from javascript? The xml-rpc server is not a zope server it is a perl script that is running on my local computer. Ideally this is what I what to do, I want to click on a link and onclick will call a javascript function and that function will call a xml-rpc method, this will all occur in my zope page template. Sounds basic, but I don't know where to start. I just started learning xml-rpc so I don't know all of the technicalities behind it, so I am so sorry for not explaining myself correctly before. Thank You, Laura On Tue, 2004-10-05 at 17:30, Laura McCord wrote:
Help.
I am so lost and frustrated. I am using xml-rpc with server-side perl modules and subroutines. But, I do not know how to access these through javascript so I can spit out the results from my zope page template.
So... the first problem is getting the jargon right here... A Zope Page Template (or a Python Script or a DTML method, etc) is capable of *generating* JavaScript code in rendered output. However this is about as much integration as there is between Zope and Javascript. Javascript operates completely within the browser and Zope really knows nothing about it. You probably know this already but it's worth repeating. In the above sentence you say "I do not know how to access these through javascript". It's unclear what "these" are in that sentence. Are you trying to access an XML-RPC server via JavaScript? Is that XML-RPC server a Zope server? Or is it some other system? If it is a Zope server, is it the same Zope server that is generating your HTML? Or is it another Zope server? (Hint: it could be any XML-RPC server). It might be advantageous to serve up the JavaScript and HTML from a system other than Zope to get a better understanding of what's going on here. You should be able to set up a static piece of HTML (maybe served up by Apache) with JavaScript in it to access an XML-RPC server (Zope or otherwise). That will make clear one source of potential confusion temporarily while you get the solution worked out. Zope will provide very little on top of whatever you devise to facilitate XML-RPC communications between the browser (in JavaScript) and whatever server you're trying to talk to. Zope's only potential contribution here is to allow you to *generate* JavaScript and it doesn't appear that you need to do that; at least you haven't mentioned needing to do it yet.
I have been using a client-side python script to access these subrountines and creating external methods to use them in my zpt, but now I need to use one of these subroutines though an 'onclick'.
I'm afraid the jargon is so mixed up here that nobody can really know what you're trying to do. What is a "client-side python script'? Why are you using external methods (these are usually only used when you're attempting to do something that the Zope security machinery won't allow you to do in a Python Script, and you make no mention of security here at all)? I *think* you're at a place where you've discovered: - an "onlick" handler in JavaScript can't call a Zope method directly; instead it can only call JavaScript code. - you need an onlick handler to do something that effects the Zope server; this must be implemented in JavaScript. - a good way to do this is to use XML-RPC. Is that right?
And of course, I have learned the hard way that zope can not be accessed directly through javascript. I have also been told that Epoz uses javascript in this way but after looking at Epoz I am completely lost and do not know where to start.
I am hoping that someone knows a simple or basic way of doing this for
someone like me that is a new programmer.
What you've explained that you're attempting to do is not particularly easy: there's nothing simple or basic about it unfortunately. Is there a way to do it that doesn't involve JavaScript? This would make things much easier. If not, I'd suggest trying to implement this in very, very small pieces. e.g. make a JavaScript function that does something simple like, calls an XML-RPC method that returns "1+1" and then displays the result 2 within the DOM using JavaScript, then build up from there incrementally. - C
On Wed, 2004-10-06 at 15:08, Laura McCord wrote:
Hi Chris,
If not, I'd suggest trying to implement this in very, very small pieces. e.g. make a JavaScript function that does something simple like, >calls an XML-RPC method that returns "1+1" and then displays the result 2 within the DOM using JavaScript, then build up from there incrementally.
Yes, this is my biggest problem, how do I call a simple xml-rpc method from javascript?
The xml-rpc server is not a zope server it is a perl script that is running on my local computer.
Ideally this is what I what to do, I want to click on a link and onclick will call a javascript function and that function will call a xml-rpc method, this will all occur in my zope page template. Sounds basic, but I don't know where to start.
I just started learning xml-rpc so I don't know all of the technicalities behind it, so I am so sorry for not explaining myself correctly before.
Well, doing something like XML-RPC with Javascript is like trying to get a couple of elephants dancing on tip toes. If you can, avoid such a solution completely. If not and you cannot choose your auditory (e.g. their browsers and the configuration of their browsers) consider using a plugin, for example Flash. This would work at least relieable. Javascript has no way making a request to a server, you are always tricking with loading in invisible (i)frames and stuff which is bound to a lot of restrictions even on browsers which "support" it. Regards Tino
Tino Wildenhain wrote:
Well, doing something like XML-RPC with Javascript is like trying to get a couple of elephants dancing on tip toes.
Much as it pains me to admit it, getting the user experience right sometimes requires pachyderms in tutus. ;)
If you can, avoid such a solution completely.
If not and you cannot choose your auditory (e.g. their browsers and the configuration of their browsers) consider using a plugin, for example Flash. This would work at least relieable.
Javascript has no way making a request to a server, you are always tricking with loading in invisible (i)frames and stuff which is bound to a lot of restrictions even on browsers which "support" it.
There are JavaScript libraries for making XML-RPC calls, e.g.: http://www.vcdn.org/Public/XMLRPC/ Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
Can you describe the behavior you are trying to get from the user's perspective? I am about 110% certain that there must be a simpler way. Maybe a popup window, or a frame that reloads within your page, or JavaScript calling a URL that does not return anything at all so the effect is to just send info to the server - would any of these do the trick? --Sean
-----Original Message----- From: zope-bounces+whysean=softhome.net@zope.org [mailto:zope-bounces+whysean=softhome.net@zope.org]On Behalf Of Laura McCord Sent: Wednesday, October 06, 2004 9:08 AM To: Chris McDonough; zope@zope.org Subject: RE: [Zope] using xml-rpc with javascript to access zope
Hi Chris,
If not, I'd suggest trying to implement this in very, very small pieces. e.g. make a JavaScript function that does something simple like, >calls an XML-RPC method that returns "1+1" and then displays the result 2 within the DOM using JavaScript, then build up from there incrementally.
Yes, this is my biggest problem, how do I call a simple xml-rpc method from javascript?
The xml-rpc server is not a zope server it is a perl script that is running on my local computer.
Ideally this is what I what to do, I want to click on a link and onclick will call a javascript function and that function will call a xml-rpc method, this will all occur in my zope page template. Sounds basic, but I don't know where to start.
I just started learning xml-rpc so I don't know all of the technicalities behind it, so I am so sorry for not explaining myself correctly before.
Thank You, Laura
Laura McCord wrote:
Hi Chris,
If not, I'd suggest trying to implement this in very, very small pieces. e.g. make a JavaScript function that does something simple like, >calls an XML-RPC method that returns "1+1" and then displays the result 2 within the DOM using JavaScript, then build up from there incrementally.
Yes, this is my biggest problem, how do I call a simple xml-rpc method from javascript?
The xml-rpc server is not a zope server it is a perl script that is running on my local computer.
Ideally this is what I what to do, I want to click on a link and onclick will call a javascript function and that function will call a xml-rpc method, this will all occur in my zope page template. Sounds basic, but I don't know where to start.
I just started learning xml-rpc so I don't know all of the technicalities behind it, so I am so sorry for not explaining myself correctly before.
I have got something similar working. Go a couple of clicks into http://caeep2.edtl.vt.edu/bozquiz , do a couple of questions to see what it does, and save the source for review. All my xmlrpc is going to the same server as the page; this may be the only way to make it work due to browser security. I have not tried to do anything different than that. The vast majority of the javascript is vcxmlrpc.js; right after that is the code that links the vcxmlrpc to the methods on the zope server. Then, of course, more javascript, css, and finally the html to hang it all on. It's not all really pretty code, but it does the job. Hope this helps. -Jim Washington
Il mer, 2004-10-06 alle 15:08, Laura McCord ha scritto:
Yes, this is my biggest problem, how do I call a simple xml-rpc method from javascript?
Have a look at http://www.vcdn.org/Public/XMLRPC/examples.php Also, mozilla has its own xml-rpc internal lib.. Alberto
participants (6)
-
Alberto Berti -
Jim Washington -
Laura McCord -
Sean Hastings -
Tino Wildenhain -
Tres Seaver