在Plone 2.5x到Plone 3.x迁移之后,如何更正kss_generic_macros问题?

时间:2021-11-18 07:23:41

I get the error below on several views. Which seems identical to what is described here in this other kss_generic_macros post. An answer is supplied, which is "This was caused by the 2.5->3.0 migration process failing to add the plone_kss layer to a handful of our custom skins. When I went in and added plone_kss by hand to those skins, it fixed this."

我在几个视图中得到了以下错误。这看起来与其他kss_generic_macros帖子中描述的相同。提供了一个答案,“这是由2.5-> 3.0迁移过程导致无法将plone_kss层添加到我们的一些自定义皮肤中。当我进入并手动将plone_kss添加到这些皮肤时,它修复了这个问题。 “

This is only so helpful. A code sample or a real pointer as to where you add plone_kss would make this much easier to solve.

这只是非常有帮助的。关于添加plone_kss的位置的代码示例或实际指针将使这更容易解决。

2009-06-24 15:24:28 ERROR Zope.SiteErrorLog 1245871468.060.103936823493 https://nasascience.on.my.mac/humanator-folder/what-is-six-plus-3/base_view
Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 216, in _exec
  Module Products.CacheSetup.patch_cmf, line 29, in FSPT_pt_render
  Module Products.CacheSetup.patch_utils, line 9, in call_pattern
  Module Products.CMFCore.FSPageTemplate, line 155, in pt_render
  Module Products.CacheSetup.patch_cmf, line 77, in PT_pt_render
  Module Products.CacheSetup.patch_utils, line 9, in call_pattern
  Module Products.PageTemplates.PageTemplate, line 98, in pt_render
  Module zope.pagetemplate.pagetemplate, line 117, in pt_render
   - Warning: Macro expansion failed
   - Warning: exceptions.KeyError: 'macro'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 525, in do_optTag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 957, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 525, in do_optTag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 949, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 861, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 891, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 536, in do_optTag_tal
  Module zope.tal.talinterpreter, line 521, in do_optTag
  Module zope.tal.talinterpreter, line 516, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 870, in do_useMacro
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:/Users/danny/projects/schwa/2.1.0a/trunk/eggs/Products.Archetypes-1.5.10-py2.4.egg/Products/Archetypes/skins/archetypes/base.pt
   - Line 22, Column 10
   - Expression: <PathExpr standard:u'here/kss_generic_macros/macros/generic_title_view'>
   - Names:
      {'container': <PloneSite at /msrd>,
       'context': <Humanatorquestion at /msrd/humanator-folder/what-is-six-plus-3>,
       'default': <object object at 0x1bf528>,
       'here': <Humanatorquestion at /msrd/humanator-folder/what-is-six-plus-3>,
       'loop': {},
       'nothing': None,
       'options': {'args': ()},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0x9ea75f8>,
       'request': <HTTPRequest, URL=https://nasascience.on.my.mac/humanator-folder/what-is-six-plus-3/base_view>,
       'root': <Application at >,
       'template': <FSPageTemplate at /msrd/base_view used for /msrd/humanator-folder/what-is-six-plus-3>,
       'traverse_subpath': [],
       'user': <PloneUser 'admin'>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 155, in _eval
  Module zope.tales.expressions, line 124, in _eval
  Module Products.PageTemplates.Expressions, line 82, in boboAwareZopeTraverse
  Module OFS.Traversable, line 301, in restrictedTraverse
  Module OFS.Traversable, line 269, in unrestrictedTraverse
   - __traceback_info__: ([], 'kss_generic_macros')
AttributeError: kss_generic_macros

2 个解决方案

#1


Log into the ZMI then go to the portal_skins tool. Now click on the "properties" tab. The "Plone Default" skin should look something like this:

登录ZMI然后转到portal_skins工具。现在单击“属性”选项卡。 “Plone Default”皮肤看起来像这样:

custom
cmfeditions_views
CMFEditions
ChangeSet
kupu_plone
kupu
kupu_tests
archetypes
archetypes_kss
mimetypes_icons
plone_kss
ATContentTypes
ATReferenceBrowserWidget
ResourceRegistries
PasswordReset
gruf
plone_ecmascript
plone_wysiwyg
plone_prefs
plone_portlets
plone_templates
plone_styles
plone_form_scripts
plone_scripts
plone_forms
plone_images
plone_content
plone_login
plone_deprecated
plone_3rdParty
cmf_legacy

If you are missing any of those you'll need to add them in. That should solve the issue.

如果你遗漏了任何你需要添加它们的东西。那应该可以解决问题。

#2


You are missing the plone_kss layer in your skins. Go to the ZMI (via site setup or by adding /manage to your Plone homepage), find the portal_skins tool, and check your skin layers in the properties tab. Make sure the plone_kss layer is listed before the custom layer and you should be set to go.

您缺少皮肤中的plone_kss图层。转到ZMI(通过站点设置或通过添加/管理您的Plone主页),找到portal_skins工具,并在属性选项卡中检查您的皮肤层。确保plone_kss图层列在自定义图层之前,您应该设置为go。

In future, you can use a command line tool like find to locate missing skin methods; I found this one in a buildout by using the following command:

将来,您可以使用find之类的命令行工具来查找缺少的皮肤方法;我使用以下命令在buildout中找到了这个:

$ find parts/plone -name kss_generic_macros.*
parts/plone/CMFPlone/skins/plone_kss/kss_generic_macros.pt

You can automate this with the following Python Script:

您可以使用以下Python脚本自动执行此操作:

from Products.CMFCore.utils import getToolByName
layer = 'plone_kss'
skins = getToolByName(context, 'portal_skins')
for name in skins.getSkinSelections():
    path = skins.getSkinPath(name)
    path = [i.strip() for i in path.split(',')]
    if layer not in path:
        try:
            path.insert(path.index('custom') + 1, layer)
        except ValueError:
            path.append(layer)
        skins.addSkinSelection(name, ','.join(path))

This script loops over all skins in the skins tool, and will insert plone_kss into any one of them where it is missing; either just after the custom layer, or at the end if there is no custom layer present.

这个脚本循环遍历皮肤工具中的所有皮肤,并将plone_kss插入到缺少它们的任何一个皮肤中;或者在自定义图层之后,或者在最后没有自定义图层的情况下。

The reason you want your custom layer to be first is that this layer by custom (no pun intended) holds customized versions of skin assets. If you were to customize an asset from the portal_kss layer through the ZMI then the customized version will be put in the custom layer. Because skin lookup rules will look through the layer stack top-to-bottom, you want to make sure your customized versions in the custom layer are found before the originals in the lower layers.

您希望自定义图层首先出现的原因是该图层是自定义的(无双关语),它包含自定义版本的皮肤资源。如果您要通过ZMI从portal_kss层自定义资产,则自定义版本将放入自定义层。由于皮肤查找规则将从上到下透视图层堆栈,因此您需要确保在较低层中的原始图像之前找到自定义图层中的自定义版本。

#1


Log into the ZMI then go to the portal_skins tool. Now click on the "properties" tab. The "Plone Default" skin should look something like this:

登录ZMI然后转到portal_skins工具。现在单击“属性”选项卡。 “Plone Default”皮肤看起来像这样:

custom
cmfeditions_views
CMFEditions
ChangeSet
kupu_plone
kupu
kupu_tests
archetypes
archetypes_kss
mimetypes_icons
plone_kss
ATContentTypes
ATReferenceBrowserWidget
ResourceRegistries
PasswordReset
gruf
plone_ecmascript
plone_wysiwyg
plone_prefs
plone_portlets
plone_templates
plone_styles
plone_form_scripts
plone_scripts
plone_forms
plone_images
plone_content
plone_login
plone_deprecated
plone_3rdParty
cmf_legacy

If you are missing any of those you'll need to add them in. That should solve the issue.

如果你遗漏了任何你需要添加它们的东西。那应该可以解决问题。

#2


You are missing the plone_kss layer in your skins. Go to the ZMI (via site setup or by adding /manage to your Plone homepage), find the portal_skins tool, and check your skin layers in the properties tab. Make sure the plone_kss layer is listed before the custom layer and you should be set to go.

您缺少皮肤中的plone_kss图层。转到ZMI(通过站点设置或通过添加/管理您的Plone主页),找到portal_skins工具,并在属性选项卡中检查您的皮肤层。确保plone_kss图层列在自定义图层之前,您应该设置为go。

In future, you can use a command line tool like find to locate missing skin methods; I found this one in a buildout by using the following command:

将来,您可以使用find之类的命令行工具来查找缺少的皮肤方法;我使用以下命令在buildout中找到了这个:

$ find parts/plone -name kss_generic_macros.*
parts/plone/CMFPlone/skins/plone_kss/kss_generic_macros.pt

You can automate this with the following Python Script:

您可以使用以下Python脚本自动执行此操作:

from Products.CMFCore.utils import getToolByName
layer = 'plone_kss'
skins = getToolByName(context, 'portal_skins')
for name in skins.getSkinSelections():
    path = skins.getSkinPath(name)
    path = [i.strip() for i in path.split(',')]
    if layer not in path:
        try:
            path.insert(path.index('custom') + 1, layer)
        except ValueError:
            path.append(layer)
        skins.addSkinSelection(name, ','.join(path))

This script loops over all skins in the skins tool, and will insert plone_kss into any one of them where it is missing; either just after the custom layer, or at the end if there is no custom layer present.

这个脚本循环遍历皮肤工具中的所有皮肤,并将plone_kss插入到缺少它们的任何一个皮肤中;或者在自定义图层之后,或者在最后没有自定义图层的情况下。

The reason you want your custom layer to be first is that this layer by custom (no pun intended) holds customized versions of skin assets. If you were to customize an asset from the portal_kss layer through the ZMI then the customized version will be put in the custom layer. Because skin lookup rules will look through the layer stack top-to-bottom, you want to make sure your customized versions in the custom layer are found before the originals in the lower layers.

您希望自定义图层首先出现的原因是该图层是自定义的(无双关语),它包含自定义版本的皮肤资源。如果您要通过ZMI从portal_kss层自定义资产,则自定义版本将放入自定义层。由于皮肤查找规则将从上到下透视图层堆栈,因此您需要确保在较低层中的原始图像之前找到自定义图层中的自定义版本。