使用 quintagroup.transmogrifier 通用设置导入设置默认页面不灵巧

发布于 2024-11-14 15:25:16 字数 1121 浏览 2 评论 0原文

我们使用 quintagroup.transmogrifier 内容导入配置文件来加载自动化测试的内容(非常有用)。设置默认页面似乎不起作用。

文档建议 quintagroup.transmogrifier 支持设置默认页面,但不支持通用设置导入步骤。我最终发现您需要将一个properties.xml文件添加到文件夹项目的文件夹中,其中包含以下内容:

<?xml version="1.0" encoding="utf-8"?>
<properties>
    <property name="default_page" type="string">
        index
    </property>
</properties>

其中index被默认页面的id替换,并且也在您需要的import.cfg中

[transmogrifier]
pipeline =
    reader
    …
    propertiesimporter

[reader]
…
.properties.xml = propertymanager

[propertiesimporter]
blueprint = quintagroup.transmogrifier.propertiesimporter

但是这不起作用。我们正在运行 Plone 4.1rc3 + Dexterity 1.0,可能它与 Dexterity 不兼容。我已经在 quintagroup.transmogrifier.propertymanager.PropertiesImporterSection 中找到了它失败的部分代码:

        path = item[pathkey]
        obj = self.context.unrestrictedTraverse(path, None)

Here path 是一个 unicode 字符串,unrestrictedTraverse 返回 None 。如果您使用字节字符串,那么它会返回正确的对象。这是与敏捷不兼容还是我做错了什么?

We're using a quintagroup.transmogrifier content import profile to load content for our automated tests (very useful). Setting the default page doesn't seem to work.

The docs suggest quintagroup.transmogrifier supports setting default pages but not whether it does for generic set-up import steps. I eventually figured out you need to add a properties.xml file into the folder of the folderish item with the following:

<?xml version="1.0" encoding="utf-8"?>
<properties>
    <property name="default_page" type="string">
        index
    </property>
</properties>

where index is replaced by the id of the default page and also in your import.cfg you need

[transmogrifier]
pipeline =
    reader
    …
    propertiesimporter

[reader]
…
.properties.xml = propertymanager

[propertiesimporter]
blueprint = quintagroup.transmogrifier.propertiesimporter

However this doesn't work. We're running Plone 4.1rc3 + Dexterity 1.0 and presumably it's not compatible with Dexterity. I've tracked down the bit of code in quintagroup.transmogrifier.propertymanager.PropertiesImporterSection where it is falling down:

        path = item[pathkey]
        obj = self.context.unrestrictedTraverse(path, None)

Here path is a unicode string and unrestrictedTraverse returns None. If you use a byte string then it returns the correct object. Is this an incompatibility with Dexterity or am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残月升风 2024-11-21 15:25:16

这是一个错误,您需要向 quintagroup.transmogrifier 包的作者报告。路径必须始终是 ASCII 字节字符串,而不是 Unicode 对象。 Collective.transmogrifier(quintagroup.transmogrifier 使用的底层引擎)中的所有部分都将路径编码为 ASCII。

这是来自 collective.transmogrifier.sections.constructor 例如:

     type_, path = item[typekey], item[pathkey]

     fti = self.ttool.getTypeInfo(type_)
     if fti is None:                           # not an existing type
         yield item; continue

     path = path.encode('ASCII')
     elems = path.strip('/').rsplit('/', 1)
     container, id = (len(elems) == 1 and ('', elems[0]) or elems)
     context = self.context.unrestrictedTraverse(container, None)

将其报告给Plone.org 上的专用问题跟踪器,以便作者可以为您修复它。

This is a bug you'll need to report with the authors of the quintagroup.transmogrifier package. Paths must always be ASCII bytestrings, not Unicode objects. All sections in collective.transmogrifier (the underlying engine that quintagroup.transmogrifier uses) encode paths to ASCII.

Here is a code snippet from collective.transmogrifier.sections.constructor for example:

     type_, path = item[typekey], item[pathkey]

     fti = self.ttool.getTypeInfo(type_)
     if fti is None:                           # not an existing type
         yield item; continue

     path = path.encode('ASCII')
     elems = path.strip('/').rsplit('/', 1)
     container, id = (len(elems) == 1 and ('', elems[0]) or elems)
     context = self.context.unrestrictedTraverse(container, None)

Report it to the dedicated issue tracker on Plone.org so the authors can fix it for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文