[Zope] ZPublisher.Client misleading exceptions
R.Taylor@eris.dera.gov.uk
R.Taylor@eris.dera.gov.uk
Wed, 22 Dec 1999 12:27:50 +0000
We are using ZPublisher.Client to call a "manage_add...." function to create a
ZClass instance. We are seeing some strange exceptions.
The "manage_add" function works through the web management interface but when
called from ZPublisher.Client it creates the instance and then generates an
exception.
In the following code place, uname, pwd are strings and kw is a dictionary.
place is 'http://zopehost/folder/manage_addProduct/Comment/manage_addComment'
def go(place,uname,pwd,kw):
import Client
return(apply(Client.Function(place,username=uname, password=pwd), (), kw))
The desired object is created, however an exception is also generated.
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "autoadd.py", line 14, in addComment
go(place,uname,pwd,kw)
File "autoadd.py", line 6, in go
return(apply(Client.Function(place,username=uname, password=pwd), (), kw))
File "/usr/local/Zope-2.0.1-linux2-x86/lib/python/ZPublisher/Client.py", line 225, in __call__
self.handleError(query, ec, em, headers, response)
File "/usr/local/Zope-2.0.1-linux2-x86/lib/python/ZPublisher/Client.py", line 240, in handleError
raise t, RemoteException(t,v,f,l,self.url,query,ec,em,response)
bci.ServerError: 302 (File: Unknown Line: Unknown)
302 Moved Temporarily for http://aedmondson:8080/Ed/manage_addProduct/Comment/manage_addComment
Whereas creating this object through the ZOPE management interface no error
occurs, and we get redirected to the correct management page.
Can anyone explain this exception and why it is being generated.
On a related note:
When trying to create an object with a already-used id (using the code above)
through the ZPublisher.Client we get the following exception.
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "autoadd.py", line 14, in addComment
go(place,uname,pwd,kw)
File "autoadd.py", line 6, in go
return(apply(Client.Function(place,username=uname, password=pwd), (), kw))
File "/usr/local/Zope-2.0.1-linux2-x86/lib/python/ZPublisher/Client.py", line 225, in __call__
self.handleError(query, ec, em, headers, response)
File "/usr/local/Zope-2.0.1-linux2-x86/lib/python/ZPublisher/Client.py", line 240, in handleError
raise t, RemoteException(t,v,f,l,self.url,query,ec,em,response)
bci.NotFound: <HTML><HEAD><TITLE>Ed's discussions test</TITLE></HEAD><BODY BGCOLOR="#FFFFFF"> <TABLE BORDER="0" WIDTH="100%"> <TR VALIGN="TOP"> <TD WIDTH="10%" ALIGN="CENTER"> <IMG SRC="http://aedmondson/p_/ZButton" ALT="Zope"> </TD> <TD WIDTH="90%"> <H2>Zope Err (File: /usr/local/Zope-2.0.1-linux2-x86/lib/python/OFS/ObjectManager.py Line: 209)
400 Bad Request for http://aedmondson:8080/Ed/manage_addProduct/Comment/manage_addComment
Whereas through the ZOPE management interface attempting to create an instance
with same id produced this:
<H2>Zope Error</H2>
<P>Zope has encountered an error while publishing this resource.
</P>
<P>
<STRONG>Error Type: Bad Request</STRONG><BR>
<STRONG>Error Value: The id 1 is invalid - it is already in use.</STRONG><BR>
</P>
We fully except to get the error but the error from the web management interface
is much more informative. How do we access this useful diagnostics from
ZPublisher.Client.
Thanks for your help.
Thanks,
Richard
Ed