[Zope] Error publishing resource

Paul Winkler pw_lists at slinkp.com
Sun Aug 29 14:28:48 EDT 2004


On Sun, Aug 29, 2004 at 06:43:47PM +0200, Garito wrote:
> Hi all
> 
> I have some code like these:
> 
> def __bobo_traverse__(self, REQUEST, name):
>    obj = getattr(self, name, None)
>        if obj is not None:
>            return obj
>        else:
>            return 'cocohuaha'
> 
> But zope raise an The object at http://myserver:8080/TestingZope/Test is 
> not publishable.
> 
> Why?
> 
> Thank you!

A good clue is to grep the zope source for that error message.
If you do, you will find that strings (and most built-in python types)
are not directly publishable.  

See for yourself in BaseRequest.traverse() in 
lib/python/ZPublisher/BaseRequest.py:


                # Hack for security: in Python 2.2.2, most built-in types
                # gained docstrings that they didn't have before. That caused
                # certain mutable types (dicts, lists) to become publishable
                # when they shouldn't be. The following check makes sure that
                # the right thing happens in both 2.2.2+ and earlier versions.
                
                if not typeCheck(subobject):
                    return response.debugError(
                        "The object at %s is not publishable." % URL
                        )


... 

itypes = {}
for name in ('NoneType', 'IntType', 'LongType', 'FloatType', 'StringType',
             'BufferType', 'TupleType', 'ListType', 'DictType', 'XRangeType',
             'SliceType', 'EllipsisType', 'UnicodeType', 'CodeType',
             'TracebackType', 'FrameType', 'DictProxyType'):
    if hasattr(types, name):
        itypes[getattr(types, name)] = 0

def typeCheck(obj, deny=itypes):
    # Return true if its ok to publish the type, false otherwise.
    return deny.get(type(obj), 1)



-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list