【问题标题】:Choose a profile when installing a quickinstaller product (Plone 4)安装 quickinstaller 产品时选择配置文件 (Plone 4)
【发布时间】:2014-04-14 09:20:23
【问题描述】:

在我的 Plone 4 应用程序中动态加载 MathJax 时遇到性能问题。因此,我在https://github.com/collective/collective.mathjax 找到了 Plone 集成,并且,正如我注意到的那样,它分叉了它,效果很好;我包含了当前的 MathJax 2.3 并更改了配置文件以使用“本地”副本。

现在我想知道是否可以通过在将产品安装到Plone QuickInstaller 工具

我像这样更改了configure.zcml

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="collective.mathjax">

  <browser:resourceDirectory
      name="mathjax"
      directory="resources/MathJax" />

  <genericsetup:registerProfile
      name="default"
      title="collective.mathjax: default"
      directory="profiles/default"
      description="collective.mathjax default profile: Includes MathJax 2.3."
      provides="Products.GenericSetup.interfaces.EXTENSION" />

  <genericsetup:registerProfile
      name="online"
      title="collective.mathjax: online"
      directory="profiles/online"
      description="collective.mathjax online profile: Load MathJax dynamically from rackcdn.com."
      provides="Products.GenericSetup.interfaces.EXTENSION" />

</configure>

很遗憾,我在 QuickInstaller 中看不到“在线”配置文件,即使在卸载产品并更改版本号之后也是如此。

更新:在控制台输出中,我发现了以下文字:

INFO CMFQuickInstallerTool 为产品 collective.mathjax 找到多个扩展配置文件。使用的个人资料:collective.mathjax:default

是否存在一些根本性的误解,或者我可以做些什么来让人们选择?

【问题讨论】:

  • 测试你的fork,两个配置文件都显示出来并且可以正确安装。无法重现您的问题。
  • 附加信息:在创建新的 Plonesite 时,我指的是表单中的产品列表。在那里,两个配置文件都出现了。有关在创建站点后安装产品,请参阅 keul 的回答。
  • 如果我理解正确,配置文件的选择适用于全新站点对象的特殊情况,但在将产品添加到现有站点时则不行。这在我看来不太一致……但确实如此。
  • 是的,您理解正确。而且是的,它是不一致的,分别是不同的激活配置文件的方式:在表单上创建站点时,或者在通过portal_setup-import 创建站点之后。不过问题不大,恕我直言。

标签: plone mathjax plone-4.x


【解决方案1】:

Plone Quickinstaller(ZMI 和 Plone UI)只会将一个配置文件显示为“安装”配置文件。被选中的将是第一个找到的(按字母顺序)。

要手动运行配置文件,请转到 ZMI 中的portal_setup 工具,然后转到“导入”选项卡并选择您想要的配置文件(此处提供的顺序是一团糟...您可能会发现一个很长的组合框)。在页面末尾选择“导入所有步骤

【讨论】:

  • 好的,我试过了。之后,我有了两个配置文件的定义......因此,我的结论是:Plone Quickinstaller 不打算提供替代配置文件的选择;当我手动运行一个时,另一个不会被删除。因此,我需要另辟蹊径。
  • 对不起,我部分误解了你的问题:不,它们不是“替代”配置文件。配置文件是一组将被执行和“做事”的配置操作。提供清理垃圾的卸载配置文件是您的职责(在这种情况下:第三部分产品)。您可以手动创建卸载配置文件(将其添加到产品代码中)。我写了一篇关于如何卸载 Plone 产品的指南:blog.keul.it/2013/05/…
  • 答案在您的评论中:没有像 alternative 配置文件这样的东西(这使得 profile 对 IMO 的野兽来说有点误导性的名称)。如果您将此作为答案,我会接受。
【解决方案2】:

实际上可以在 Quickinstaller 中显示多个“替代”配置文件 - 您只需要通过为自己的(子)包注册每个配置文件来“欺骗”GenericSetup。

因此,诀窍是将配置文件定义放在位于不同包(目录)中的不同 configure.zcml 文件中,并确保在每个 configure.zcml 文件中包含 &lt;five:registerPackage package="."/&gt; 指令。

虽然它有效,但我不确定这个技巧是否值得推荐:我在 dexterity.membrane 包中找到了它,此处用作示例:

首先,“默认”配置文件在dexterity.membrane 包的主configure.zcml 中完全正常注册。没什么特别的 - 但请注意,它包含 content 子包

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="dexterity.membrane">

  <!-- Include configuration for dependencies listed in setup.py -->
  <includeDependencies package="." />
  <!-- Grok the package to initialise schema interfaces and content classes -->

  <i18n:registerTranslations directory="locales" />

  <include package=".behavior" />
  <include package=".content" />

  <!-- Register an extension profile to make the product installable -->
  <genericsetup:registerProfile
      name="default"
      title="dexterity.membrane: behaviors"
      description="Configuration for the dexterity.membrane behaviors"
      directory="profiles/default"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />
  <!-- Note that the example profile is registered in the content
       directory.  It is registered in such a way that both profiles
       are visible and can be installed separately.  Any upgrade steps
       for that profile are also defined there. -->

  <genericsetup:upgradeStep
      title="Update profile"
      description="Dummy step to fix profile registration after rename."
      source="1000"
      destination="1001"
      handler="dexterity.membrane.migration.dummy_step"
      profile="dexterity.membrane:default" />

  <adapter name="Title" factory=".indexers.Title" />

  <!-- -*- extra stuff goes here -*- -->

</configure>

这是上述content subpackageconfigure.zcml:也没什么特别的,除了(第二个)registerPackage 指令和第二个配置文件

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    i18n_domain="dexterity.membrane">

  <!-- make this show up in the quickinstaller separately -->
  <five:registerPackage package="."/>

  <genericsetup:registerProfile
      name="example"
      title="dexterity.membrane: content"
      description="Configuration for the dexterity.membrane example content type"
      directory="../profiles/example"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />

</configure>

【讨论】:

    【解决方案3】:

    从 Ida 和 Keul 的有用的 cmets 中回答:

    • (不幸的是)没有替代配置文件之间的选择(这使得“配置文件”这个名称在这里有点误导,IMO)。
    • 为了在配置文件之间切换,我最终得到了不同的分支。这个过程是这样的:
      • 转到产品目录并切换到所需的分支,例如git checkout &lt;branch name&gt;
      • 重启 Plone(否则它不会注意到变化,除非同时有新的版本号)
      • 重新安装产品;
      • 一切顺利后,更新buildout.cfg 以反映更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多