使用 Python 脚本从 Plone 中检索对象的内容

Retrieve contents of objects from Plone using Python script

我正在使用 Plone 5。我添加了一个 Python 脚本,我想做的是获取其中一个文件夹中包含的对象并打印它们。我使用 context.restrictedTraverse(path) 通过路径获取对象,但它只有 returns <Document at path> 。有没有人有什么建议? 谢谢!

你只是遍历到文档。

此处列出了一些获取文件夹子项的可能方法。

>>> # List all children without security checks
>>> context.restrictedTraverse(path).objectValues()

>>> # List all ids without security checks
>>> context.restrictedTraverse(path).objectIds()

>>> # List all ids/values without security checks
>>> context.restrictedTraverse(path).contentItems()

>>> # You can use the catalog, this includes security checks and more.
>>> # This will return a catalog results (brains), not the actual object.
>>> context.restrictedTraverse(path).objectIds().getFolderContents()

有关更多信息,请查看 plone 文档页面:http://docs.plone.org/develop/plone/content/listing.html