Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customActions from plone.supermodel are being called before all config are done when using plone.app.testing #39

Open
idgserpro opened this issue Mar 30, 2017 · 11 comments

Comments

@idgserpro
Copy link

idgserpro commented Mar 30, 2017

This happened in collective.cover's PR after Plone 4.3.12 release.

Using Plone 4.3.11, collective.cover tests were working. They stopped working in 4.3.12. We detected (by doing a pdb in supermodel finalizeSchema) that the cause is cover's supermodel fields that aren't "loaded". supermodel needs to execute a customAction after all zcml are loaded. For some zcml dependency we didn't detected yet, in Plone 4.3.12, supermodel is loaded along packages that plone.app.testing loads. At that moment, cover's zcml isn't loaded yet so supermodel's customAction don't consider cover configurations, giving the error.

When bin/instance is called, xmlconfig.file is called only one time. When bin/test is called, xmlconfig.file is called for each package in products. So the customActions are executed multiple times in bin/test making customActions of supermodel being executed before collective.cover's configuration.

We don't know which package in

caused the error.

@idgserpro
Copy link
Author

idgserpro commented Apr 3, 2017

Investigating a little more, I discovered that isn't the collective.cover that needs to be loaded before the finalizeSchema function is executed, but rather the plone.autoform (which is used by the cover).

I also discovered that the finalizeSchema function is called when the Products.TinyMCE is loaded. At this moment, the plone.autoform isn't loaded yet.

We could just add the plone.autoform into the products variable, before Products.TinyMCE. But that could give trouble in the future, as it did now.

So I suggest add:

<include zcml:condition="installed plone.autoform" package="plone.autoform" />

before this supermodel line. Thus, we ensure that the plone.autoform will always be loaded in the tests, before the finalizeSchema function is called.

@mauritsvanrees @davisagli @hvelarde opinions?

@hvelarde
Copy link
Member

hvelarde commented Apr 3, 2017

I can't help on this; sorry but it's out of my current knowledge.

hvelarde added a commit to collective/collective.cover that referenced this issue Apr 4, 2017
hvelarde added a commit to collective/collective.cover that referenced this issue Apr 4, 2017
* Use Firefox 45.8.0esr instead of latest-esr

* Use getIcon from plone_layout helper view

This method was deprecated and has been removed from Plone 5.1.

* Remove image traverses test from basic tile

The test makes no sense as it was implemented and is failing with newer versions of Pillow.

* Use Plone 4.3.11 for tests on 4.3 branch

Refs: plone/plone.app.testing#39

* Use plone.api 1.6 on builds using Archetypes

See: plone/plone.api#364
@mauritsvanrees
Copy link
Member

That seems to make sense, and it fixes the problems with the collective.cover tests.
+1 on making that change to include plone.autoform zcml.

@mauritsvanrees
Copy link
Member

@idgserpro When I try your fix and run the plone.supermodel tests in coredev 4.3, I get lots of test failures:

        ZopeXMLConfigurationError: File "/Users/maurits/community/plone-coredev/4.3/src/plone.supermodel/plone/supermodel/configure.zcml", line 8.4-9.35
        ZopeXMLConfigurationError: File "/Users/maurits/shared-eggs/plone.autoform-1.6.2-py2.6.egg/plone/autoform/configure.zcml", line 5.4-5.39
        ZopeXMLConfigurationError: File "/Users/maurits/shared-eggs/plone.z3cform-0.8.1-py2.6.egg/plone/z3cform/configure.zcml", line 9.2-9.35
        ZopeXMLConfigurationError: File "/Users/maurits/shared-eggs/plone.z3cform-0.8.1-py2.6.egg/plone/z3cform/templates.zcml", line 12.2
        ConfigurationError: ('Unknown directive', u'http://namespaces.zope.org/browser', u'page')

The zcml file from the last line seems innocent: the directive is there.

So while it seemed okay, this is not the right solution.

@idgserpro
Copy link
Author

@mauritsvanrees really weird. Like you said, the directive is there.

When I have the time, I take a look at coredev.

@idgserpro
Copy link
Author

idgserpro commented Apr 5, 2017

@mauritsvanrees the problem is that coredev tests include plone.autoform egg. It is not an isolated test with only plone.supermodel dependencies. Then the condition:

zcml:condition="installed plone.autoform"

will be true and the plone.autoform zcml will be included in the plone.supermodel tests. The test needs to be reviewed considering this.

@idgserpro
Copy link
Author

@mauritsvanrees for the directive to work, it's necessary load the Products.Five into the supermodel tests. Then you need to add:

<include package="Products.Five" file="configure.zcml" />

in
test.py
directives.txt
fields.txt
schema.txt

In addition, you need to change the schema.txt test to consider the plone.autoform directives, which are now loaded:

Failure in test /home/user/buildout.coredev/src/plone.supermodel/plone/supermodel/schema.txt
Failed doctest test for schema.txt
  File "/home/user/buildout.coredev/src/plone.supermodel/plone/supermodel/schema.txt", line 0

----------------------------------------------------------------------
File "/home/user/buildout.coredev/src/plone.supermodel/plone/supermodel/schema.txt", line 110, in schema.txt
Failed example:
    print serializeModel(model) # doctest: +NORMALIZE_WHITESPACE
Expected:
    <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns="http://namespaces.plone.org/supermodel/schema">
      <schema>
        <field name="title" type="zope.schema.TextLine">
          <title>Title</title>
        </field>
        <field name="description" type="zope.schema.Text">
          <description>A short summary</description>
          <min_length>10</min_length>
          <required>False</required>
          <title>Description</title>
        </field>
      </schema>
    </model>
Got:
    <model xmlns:i18n="http://xml.zope.org/namespaces/i18n" xmlns:security="http://namespaces.plone.org/supermodel/security" xmlns:form="http://namespaces.plone.org/supermodel/form" xmlns="http://namespaces.plone.org/supermodel/schema">
      <schema>
        <field name="title" type="zope.schema.TextLine">
          <title>Title</title>
        </field>
        <field name="description" type="zope.schema.Text">
          <description>A short summary</description>
          <min_length>10</min_length>
          <required>False</required>
          <title>Description</title>
        </field>
      </schema>
    </model>

@hvelarde
Copy link
Member

here's a screenshot of the actual error:

selenium-screenshot-1

according to the changelog there's nothing in this package that has changed in order to create that problem; IMO this issue has to be closed and we need to continue looking for what is causing the problem.

@hvelarde
Copy link
Member

I describing the issue in dept here: collective/collective.cover#759

I already have a workaround.

@idgserpro
Copy link
Author

@hvelarde The problem is already described here, I didn't get it why you opened another one in collective.cover...

@mauritsvanrees can you help us here? We gave two suggestions on how to solve the problem:

#39 (comment)

#39 (comment)

If you don't agree in plone.autoform influencing plone.supermodel tests, can you at least analyse adding plone.autoform before TinyMCE in

('Products.TinyMCE' , {'loadZCML': True}, ),
?

@hvelarde
Copy link
Member

hvelarde commented Nov 2, 2017

@davisagli can you give a clue here? I see you're the father of the creature ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants