我能做到:app.restrictedTraverse('/zport/dmd/version')
给了我'Zenoss 4.2.4'
,但是当我在浏览器中执行相同操作时,它会给我
网站错误。发布此资源时遇到错误。 请求的资源不存在。
对于dmd
对象上的某些其他值或函数,它可以正常工作。如何调试“不存在”错误,以及如何在Zope中从url到对象的映射工作?
答案 0 :(得分:0)
Citing the ZPublisher.BaseRequest.DefaultPublishTraverse.publishTraverse:
# Ensure that the object has a docstring, or that the parent
# object has a pseudo-docstring for the object. Objects that
# have an empty or missing docstring are not published.
doc = getattr(subobject, '__doc__', None)
if not doc:
raise Forbidden(
"The object at %s has an empty or missing " \
"docstring. Objects must have a docstring to be " \
"published." % URL
)
# 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):
raise Forbidden(
"The object at %s is not publishable." % URL
)
typeCheck
认为这种类型是禁止的:
('NoneType', 'IntType', 'LongType', 'FloatType', 'StringType',
'BufferType', 'TupleType', 'ListType', 'DictType', 'XRangeType',
'SliceType', 'EllipsisType', 'UnicodeType', 'CodeType',
'TracebackType', 'FrameType', 'DictProxyType', 'BooleanType',
'ComplexType')