[Zope] Part-time tracebacks

Michel Pelletier michel@digicool.com
Tue, 21 Dec 1999 09:26:15 -0500


> -----Original Message-----
> From: Phil Harris [mailto:phil.harris@zope.co.uk]
> Sent: Sunday, December 19, 1999 5:58 PM
> To: Zope@zope.org
> Subject: [Zope] Part-time tracebacks
> 
> Hi all,
> 
> I have a problem.
> 
> I have a folder that contains file objects that contain 
> text/xml.  (I know I
> could have used XMLDocuments, but I found them too slow).
> 
> These documents are being rendered to html via xsl in an 
> external method,
> using a java based xsl processor and this is pretty much 
> working well, but.
> 
> Some of the documents cause the error below, any ideas?
> 
> Error Type: TypeError
> Error Value: argument 1: expected read-only character buffer,
> ImplicitAcquirerWrapper found

Most objects in Zope are wrapped up with special wrappers that allow the
Acquisition machinery to work.  Your code is looking for a string, but
finding a wrapped object.  Zope usualy handles all of these details for
you, but when you drop down to python you have to be aware of them
sometimes.

if you wrapped object is called 'obj', then the *unwrapped* version of
that exact same object can be gotten with 'obj.aq_self'.  You can do a
simple test in python:

  if hasattr(obj, 'aq_self'):       # then it's wrapped
    obj = obj.aq_self

This will unwrap the object for you.

-Michel