Hi!
Wichert Akkerman wrote:
Previously yuppie wrote:
Wichert Akkerman wrote:
Previously yuppie wrote:
- The exports created by the new components handler are still flawed,
ISiteRoot and placeless components are not exported correctly.
I'm quite sure I fixed that: I was able to export the components and
import them again. Has that been broken since?
Don't know since when these things are broken, but in the latest code
there are these 2 bugs:
1.) Exporting the ISiteRoot utility, 'object' should be empty. But I get
this instead:
<utility interface="Products.CMFCore.interfaces._content.ISiteRoot"
object="SITE_ID"/>
2.) By placeless components I mean something like this:
<utility component="foo.bar" interface="foo.IBar"/>
The import works fine, but the export looks like this:
<utility factory="foo.Bar" interface="foo.IBar"/>
Attached is a diff for test_components.py. Unfortunately the
AssertionErrors are a bit cryptic, but they show that the factory is
exported instead of the component.
I get something else: if I import this:
<utility interface="foo.IBar" factory="foo.bar"/>
the export looks like this:
<utility interface="foo.IBar" object=""/>
That seems to be a similar but different bug.
this is caused by the zope.component.registerUtility not storing the
factory method but the return value from the factory, so we no longer
have the factory method available when we export.
The only way to fix that appears to be for us to keep a a registry of
factory methods in the setup tool. That may be too big of a change
in a minor release though.
Not sure if your issue is a problem in real life. AFAICS this only
happens if you use a factory that is meant for ZODB objects. In that
case you should register an object.
So my vote would be: document that exporting of utility factories is
currently not supported and will be fixed in GenericSetup 1.4 and
tag the current code as 1.3.1.
I'm fine with that.
Cheers,
Yuppie
Index: Products/GenericSetup/tests/test_components.py
===================================================================
--- Products/GenericSetup/tests/test_components.py (revision 78655)
+++ Products/GenericSetup/tests/test_components.py (working copy)
@@ -69,6 +69,8 @@
def verify(self):
return True
+dummy_utility = DummyUtility()
+
class DummyTool(SimpleItem):
"""A dummy tool."""
@@ -113,6 +115,9 @@
<utility name="dummy tool name2"
interface="Products.GenericSetup.tests.test_components.IDummyInterface"
object="dummy_tool2"/>
+ <utility name="dummy utility name"
+ component="Products.GenericSetup.tests.test_components.dummy_utility"
+ interface="Products.GenericSetup.tests.test_components.IDummyInterface"/>
<utility name="foo"
factory="Products.GenericSetup.tests.test_components.DummyUtility"
interface="Products.GenericSetup.tests.test_components.IDummyInterface"/>
@@ -135,6 +140,9 @@
tool2 = aq_base(self.app['dummy_tool2'])
obj.registerUtility(tool2, IDummyInterface, name=u'dummy tool name2')
+ obj.registerUtility(dummy_utility, IDummyInterface,
+ name=u'dummy utility name')
+
def test_body_get(self):
self._populate(self._obj)
context = DummyExportContext(self.app)
@@ -171,6 +179,10 @@
self.failUnless(IDummyInterface.providedBy(util))
self.failUnless(util.verify())
+ util = queryUtility(IDummyInterface, name=u'dummy utility name')
+ self.failUnless(IDummyInterface.providedBy(util))
+ self.failUnless(util.verify())
+
util = queryUtility(IDummyInterface)
self.failUnless(IDummyInterface.providedBy(util))
self.failUnless(util.verify())
_______________________________________________
Zope-CMF maillist - Zope-CMF@lists.zope.org
http://mail.zope.org/mailman/listinfo/zope-cmf
See http://collector.zope.org/CMF for bug reports and feature requests