Syntax error in XML-RPC How to?
hi: I'm trying to use the BasicAuth example in the "XML-RPC How To" http://www.zope.org/Members/Amos/XML-RPC I keep getting the Zope error when creaing the External Method: Zope has encountered an error while publishing this resource. Error Type: SyntaxError Error Value: invalid syntax -------- I've just cut and pasted this from the webpage, only removed extra padding spaces, and spliced the one big line back together: h.putheader("AUTHORIZATION", "Basic %s" % string.replace(encodestring("%s:%s" % (self.username, self.password)),"\012", "")) The code defines a class and a def: --------------- class BasicAuthTransport(xmlrpclib.Transport): def __init__(self, username=xxxx, password=xxxx): self.username=username self.password=password def request(self, host, handler, request_body): # issue XML-RPC request ---------------- In the Add External method page, where you enter in the Function name I've tried: request BasicAuthTransport BasicAuthTransport.request request.BasicAuthTransport Which is the right one? it want's the Function 'request', right? So, the syntax error must be something in the script. Any help would be appreciated. -andy
What's the traceback embedded in the HTML source of the error page? It will point you directly to where the syntax error is. -Michel Andrew Diller wrote:
hi: I'm trying to use the BasicAuth example in the "XML-RPC How To"
http://www.zope.org/Members/Amos/XML-RPC
I keep getting the Zope error when creaing the External Method:
Zope has encountered an error while publishing this resource.
Error Type: SyntaxError Error Value: invalid syntax
--------
I've just cut and pasted this from the webpage, only removed extra padding spaces, and spliced the one big line back together: h.putheader("AUTHORIZATION", "Basic %s" % string.replace(encodestring("%s:%s" % (self.username, self.password)),"\012", ""))
The code defines a class and a def:
--------------- class BasicAuthTransport(xmlrpclib.Transport): def __init__(self, username=xxxx, password=xxxx): self.username=username self.password=password
def request(self, host, handler, request_body): # issue XML-RPC request
---------------- In the Add External method page, where you enter in the Function name I've tried:
request BasicAuthTransport BasicAuthTransport.request request.BasicAuthTransport
Which is the right one? it want's the Function 'request', right?
So, the syntax error must be something in the script.
Any help would be appreciated.
-andy
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Thu, Mar 09, 2000 at 12:56:42PM -0800, Michel Pelletier wrote:
What's the traceback embedded in the HTML source of the error page?
It will point you directly to where the syntax error is.
-Michel
Well, it dosen't point to much, IMHO. Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_addExternalMethod) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_addExternalMethod) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 125, in manage_addExternalMethod File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 167, in __init__ (Object: ba) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 186, in manage_edit (Object: ba) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 195, in getFunction (Object: ba) File /usr/local/zope/lib/python/App/Extensions.py, line 205, in getObject (Info: ('/usr/local/zope/Extensions/ba.py', 'ba')) SyntaxError: (see above) I've named the python script ba.py. Is using 'request' proper for the 'Function name?' thanks, andy
Andrew Diller wrote:
On Thu, Mar 09, 2000 at 12:56:42PM -0800, Michel Pelletier wrote:
What's the traceback embedded in the HTML source of the error page?
It will point you directly to where the syntax error is.
-Michel
Well, it dosen't point to much, IMHO.
Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_addExternalMethod) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_addExternalMethod) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 125, in manage_addExternalMethod File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 167, in __init__ (Object: ba) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 186, in manage_edit (Object: ba) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 195, in getFunction (Object: ba) File /usr/local/zope/lib/python/App/Extensions.py, line 205, in getObject (Info: ('/usr/local/zope/Extensions/ba.py', 'ba')) SyntaxError: (see above)
I've named the python script ba.py.
Ah yes, I didn't realize it was in an external method. External methods mask the exact error information. Just import ba.py into a python interpreter *without* Zope and it will tell you where the error is. -Michel
Ok, my syntax error was that I was replacing the username and password with strings and not putting them in ''. That's fixed. But I'm still having an error now. Zope Traceback: ba.py is the cut and pasted XML-PRC access code request is the function in the script! What am I missing here in trying to call this from a DTML-Method? -------------------------- The specified object, request, was not found in module, ba. Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: manage_addExternalMethod) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_addExternalMethod) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 125, in manage_addExternalMethod File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 167, in __init__ (Object: ba) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 186, in manage_edit (Object: ba) File /usr/local/zope/lib/python/Products/ExternalMethod/ExternalMethod.py, line 195, in getFunction (Object: ba) File /usr/local/zope/lib/python/App/Extensions.py, line 209, in getObject (Info: ('/usr/local/zope/Extensions/ba.py', 'ba')) Invalid Object Name: (see above) -cut----
participants (2)
-
dillera@isc.upenn.edu -
Michel Pelletier