Bha*_*wat 2 python plone zcml plone-4.x
我正在为我的Plone网站开发一个新的附加组件,因此它显示了我的错误
configure.zcml : unbound prefix.
Run Code Online (Sandbox Code Playgroud)
在这里,我正在编写我的zcml代码:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="customer.reports">
<five:registerPackage package="." initialize=".initialize" />
<include package="plone.resource" file="meta.zcml"/>
<plone:static
directory="templates"
type="reports"
name="customer"
/>
</configure>
Run Code Online (Sandbox Code Playgroud)
未绑定的前缀错误如下所述.
文件"/Plone/Python-2.7/lib/python2.7/xml/sax/handler.py",第38行,在fatalError引发异常zope.configuration.xmlconfig.ZopeXMLConfigurationError:文件"/ Plone/zinstance/parts/instance/etc/site.zcml",第16.2-16.23行ZopeXMLConfigurationError:文件"/Plone/buildout-cache/eggs/Products.CMFPlone-4.3-py2.7.egg/Products/CMFPlone/configure.zcml",第98.4-102.10行ZopeSAXParseException :文件"/Plone/zinstance/src/customer.reports/customer/reports/configure.zcml",第13.2行,未绑定前缀
您的代码未定义plone您在元素中使用的前缀plone:static.您可能需要在某处添加相应的名称空间声明,例如在configure元素中:xmlns:plone="http://namespaces.plone.org/plone".
此错误表示您在configure.zcml顶部缺少名称空间声明.尝试在configure标记中包含以下内容之一:
xmlns:plone="http://namespaces.plone.org/plone"
Run Code Online (Sandbox Code Playgroud)
正如我在我的代码中添加以上行来修复未绑定错误之前我使用plone注册我的附加组件但未声明正确的命名空间即plone在zcml文件的名称空间声明块
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
xmlns:plone="http://namespaces.plone.org/plone"
i18n_domain="customer.reports">
<five:registerPackage package="." initialize=".initialize" />
<!-- -*- extra stuff goes here -*- -->
<include package="plone.resource" file="meta.zcml"/>
<plone:static
directory="templates"
type="reports"
name="customer"
/>
</configure>
Run Code Online (Sandbox Code Playgroud)