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

Can't import settings from registry.xml in v0.7.2 onwards #14

Open
djowett opened this issue Jun 16, 2015 · 10 comments
Open

Can't import settings from registry.xml in v0.7.2 onwards #14

djowett opened this issue Jun 16, 2015 · 10 comments

Comments

@djowett
Copy link

djowett commented Jun 16, 2015

Using this registry.xml

<registry>

  <record name="collective.cookiecuttr.interfaces.ICookieCuttrSettings.accept_button" interface="collective.cookiecuttr.interfaces.ICookieCuttrSettings" field="accept_button">
    <field type="plone.registry.field.List">
      <default>
        <element>{'text': u'Accept cookies', 'language': u'en'}</element>
      </default>
      <required>False</required>
      <title>Text to show in the Accept button</title>
    </field>
    <value>
      <element>{'text': u'Accept cookies', 'language': u'en'}</element>
    </value>
  </record>

</registry>

I get the following error

2015-06-16 11:17:49 ERROR Zope.SiteErrorLog 1434449869.030.24284281193 http://localhost:8088/MYSITE/portal_quickinstaller/reinstallProducts
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 48, in call_object
  Module <string>, line 6, in reinstallProducts
  Module AccessControl.requestmethod, line 70, in _curried
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 640, in reinstallProducts
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 580, in installProducts
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
   - __traceback_info__: ('antaco.policy',)
  Module Products.GenericSetup.tool, line 350, in runAllImportStepsFromProfile
   - __traceback_info__: profile-antaco.policy:default
  Module Products.GenericSetup.tool, line 1100, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 1015, in _doRunImportStep
   - __traceback_info__: plone.app.registry
  Module plone.app.registry.exportimport.handler, line 49, in importRegistry
  Module plone.app.registry.exportimport.handler, line 92, in importDocument
  Module plone.app.registry.exportimport.handler, line 190, in importRecord
  Module plone.supermodel.exportimport, line 122, in read
  Module plone.supermodel.exportimport, line 188, in readAttribute
  Module plone.supermodel.utils, line 112, in elementToValue
  Module plone.supermodel.utils, line 123, in elementToValue
TypeError: ('Could not adapt', None, <InterfaceClass zope.schema._bootstrapinterfaces.IFromUnicode>)
> /home/daniel/dev/Plone/Development/buildout-cache/eggs/plone.supermodel-1.2.3-py2.7.egg/plone/supermodel/utils.py(123)elementToValue()
-> converter = IFromUnicode(field)
(Pdb) 

I believe this is the same issue mentioned in collective/collective.z3cform.datagridfield#22

@djowett
Copy link
Author

djowett commented Jun 16, 2015

Upgrading to latest plone.supermodel (1.2.6) doesn't fix it.

Removing the <default> tag gives this error instead:

2015-06-16 11:42:54 ERROR Zope.SiteErrorLog 1434451374.590.205310419206 http://localhost:8088/MYSITE/portal_quickinstaller/reinstallProducts
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 48, in call_object
  Module <string>, line 6, in reinstallProducts
  Module AccessControl.requestmethod, line 70, in _curried
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 640, in reinstallProducts
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 580, in installProducts
  Module Products.CMFQuickInstallerTool.QuickInstallerTool, line 512, in installProduct
   - __traceback_info__: ('antaco.policy',)
  Module Products.GenericSetup.tool, line 350, in runAllImportStepsFromProfile
   - __traceback_info__: profile-antaco.policy:default
  Module Products.GenericSetup.tool, line 1100, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 1015, in _doRunImportStep
   - __traceback_info__: plone.app.registry
  Module plone.app.registry.exportimport.handler, line 49, in importRegistry
  Module plone.app.registry.exportimport.handler, line 92, in importDocument
  Module plone.app.registry.exportimport.handler, line 218, in importRecord
  Module plone.supermodel.utils, line 122, in elementToValue
  Module plone.supermodel.utils, line 134, in elementToValue
  Module plone.supermodel.converters, line 114, in fromUnicode
  Module zope.dottedname.resolve, line 32, in resolve
ImportError: No module named {'text': u'Accept cookies', 'language': u'en'}
> /home/daniel/dev/Plone/Development/buildout-cache/eggs/zope.dottedname-3.4.6-py2.7.egg/zope/dottedname/resolve.py(32)resolve()
-> found = __import__(used)
(Pdb) 

Which looks like plone.supermodel has found the wrong converter....

@djowett
Copy link
Author

djowett commented Jun 16, 2015

Adding a value_type to the field in registry.xml seems to make the import work, but unfortunately the just ends up with a TypeError: ('Could not adapt', u"{'text': u'Accept cookies', 'language': u'en'}", <InterfaceClass collective.cookiecuttr.interfaces.ITextAcceptSchema>) error on the @@cookiecuttr-settings control panel.

This means that the exporthandler is also wrong somewhere as it should set a value_type

Setting value_type to collective.z3cform.datagridfield.registry.DictRow leads to a

  Module plone.app.registry.exportimport.handler, line 49, in importRegistry
  Module plone.app.registry.exportimport.handler, line 92, in importDocument
  Module plone.app.registry.exportimport.handler, line 190, in importRecord
  Module plone.supermodel.exportimport, line 113, in read
NotImplementedError: Type collective.z3cform.datagridfield.registry.DictRow used for value_type not supported

My registry.xml now looks like this:

<registry>

  <record name="collective.cookiecuttr.interfaces.ICookieCuttrSettings.accept_button" interface="collective.cookiecuttr.interfaces.ICookieCuttrSettings" field="accept_button">
    <field type="plone.registry.field.List">
      <required>False</required>
      <title>Text to show in the Accept button</title>
      <value_type type="collective.z3cform.datagridfield.registry.DictRow"/>
    </field>
    <value>
      <element>{'text': u'Accept cookies', 'language': u'en'}</element>
    </value>
  </record>

</registry>

@djowett
Copy link
Author

djowett commented Jun 16, 2015

I'm going to leave this here for now and just pin to 0.7.1 of collective.cookiecuttr. The issue is almost certainly within collective.z3cform.datagridfield, but perhaps we could use an alternative?

Does anyone have the GS import working since 0.7.2 ?

@djowett djowett changed the title Can't import settings from registry.xml Can't import settings from registry.xml from 0.7.2 Jun 16, 2015
@djowett djowett changed the title Can't import settings from registry.xml from 0.7.2 Can't import settings from registry.xml in v0.7.2 onwards Jun 16, 2015
@djowett djowett closed this as completed Feb 29, 2016
@djowett djowett reopened this Mar 7, 2016
@djowett
Copy link
Author

djowett commented Mar 7, 2016

Still an issue don't know whether this is maybe to do with me using plone.app.contenttypes on Plone 4.3

@djowett
Copy link
Author

djowett commented Mar 9, 2016

@erral @kingel sorry to ping you directly on this, but can you just say if you've seen this problem? Should I be trying to save the settings to a GS profile or is that silly to attempt it?

@erral
Copy link
Contributor

erral commented Mar 10, 2016

Sorry... No, I haven't seen this problem before, but we didn't try to save the information in the GS profile and then import back.

@djowett
Copy link
Author

djowett commented Mar 10, 2016

Thanks for the reply.

If this isn't working, would you agree that we may need to rework the
multilanguage solution so that it does?

@erral
Copy link
Contributor

erral commented Mar 10, 2016

Yes, or at least the import/export steps.

@djowett
Copy link
Author

djowett commented Mar 10, 2016

Ok, yes - I figure the export is wrong somehow, so that's the first
thing I'll try,
but it might come to fixing the form.

@kingel
Copy link
Member

kingel commented Mar 11, 2016

No idea, but to be honest we havent used the package for years now :)

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