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

Any plans for a new release? Then we can avoid using collective.blueprint.jsonmigrator in some situations. #13

Closed
idgserpro opened this issue Oct 21, 2015 · 11 comments
Assignees
Milestone

Comments

@idgserpro
Copy link
Member

At this moment, if I want to use a json source blueprint I need https://github.com/collective/collective.blueprint.jsonmigrator, but if I want a datafields blueprint that works then I need the one from collective.jsonmigrator. You can use the JSONSource blueprint from collective.jsonmigrator but you need to register the JSONSource as an utility in your configure.zcml since it's not available in collective.jsonmigrator configure.zcml.

The problem is: when using collective.blueprint.jsonmigrator with an exported json from collective.jsonify that has a File content, I get the error

AttributeError: 'dict' object has no attribute 'startswith'

Thus I need to patch this line to properly use the json source blueprint (the datafield is a dict but the original code expects a string). This line was even removed in new versions of collective.jsonmigrator.

This situation is not optimal and really confusing since we have three moving parts: collective.blueprint.jsonmigrator, collective.jsonmigrator and a patch (and if you're using the configure.zcml approach is still a moving part).

After reading collective.jsonmigrator source code I've seen that you have added a json source along datafields blueprint. Testing Archetypes export with collective.jsonify with File content and trying to import it using collective.jsonmigrator 0.3.dev0 unreleased, it works. I'm using a Plone 4.3.7 installation.

So, creating a new 0.3 release we can ease this pain and the cruft of adding a 5 year old package just for the json source blueprint.

This is specially useful as well when creating policy packages that create default content. Here's is a simple transmogrifier.cfg and a setuphandlers.py snippet we used for testing the 0.3.dev0 unreleased collective.jsonmigrator package, after just using export_content from collective.jsonify.

[transmogrifier]

pipeline =
    source
    inserter
    folders
    constructor
    workflowupdater
    atschemaupdater
    datafields
    reindexobject

[inserter]
blueprint = collective.transmogrifier.sections.inserter
key = string:_path
value = python:item['_path'].replace('/Plone', '')

[source]
blueprint = collective.jsonmigrator.jsonsource
path = my.package:initcontent/

[folders]
blueprint = collective.transmogrifier.sections.folders

[constructor]
blueprint = collective.transmogrifier.sections.constructor

[mimetype]
blueprint = collective.jsonmigrator.mimetype

[properties]
blueprint = collective.jsonmigrator.properties

[datafields]
blueprint = collective.jsonmigrator.datafields

[atschemaupdater]
blueprint = plone.app.transmogrifier.atschemaupdater

[workflowupdater]
blueprint = plone.app.transmogrifier.workflowupdater
path-key = _path
transitions-key = _transitions

[reindexobject]
blueprint = plone.app.transmogrifier.reindexobject
from collective.transmogrifier.transmogrifier import Transmogrifier

def initcontent(portal):
    transmogrifier = Transmogrifier(portal)
    transmogrifier('my.package')

def postInstall(context):
    """Called as at the end of the setup process. """
    if not context.readDataFile('my_package_marker.txt'):
        return

    portal = context.getSite()
    initcontent(portal)
@pigeonflight
Copy link
Member

+1. I just had about 36 hours of json migration frustration. At least you've figured out a kludge in the meantime. For the rest of us this would be very useful.

@idgserpro
Copy link
Member Author

@thet Can you help us here? Would it be the case to update https://github.com/collective/collective.blueprint.jsonmigrator docs and say collective.jsonmigrator is preferred?

@thet
Copy link
Member

thet commented Oct 22, 2015

See my comments at collective/collective.jsonify#20 (comment)
I can't make a release for collective.jsonmigrator, but i use the source checkout of it. i think, collective.blueprint.jsonmigrator is outdated. I added missing blueprints from collective.blueprint.jsonmigrator into collective.jsonmigrator.

@djowett
Copy link
Contributor

djowett commented Oct 23, 2015

@idgserpro I never used collective.blueprint.jsonmigrator (though I have used collective.jsonmigrator quite a lot a year or two back). Can you clarify why you need that product? (same question to @pigeonflight too)

As I understand it, @garbas created collective.jsonmigrator as a replacement for collective.blueprint.jsonmigrator.

@idgserpro
Copy link
Member Author

@djowett you're right, there's no need for collective.blueprint.jsonmigrator. The docs we used were misleading. The JSON source is already in a blueprint.py file in collective.jsonmigrator, and it could be used instead of the one from collective.blueprint.jsonmigrator, but it's not registered in it's configure.zcml file as an utility so you need to register it in your own package. It's still a moving part. I'm talking about the 0.2 release from pypi.

But that aside, we still have a problematic line like the one in https://github.com/collective/collective.blueprint.jsonmigrator/blob/e14a5c61927f595f34a239f6c043ca18401d14a3/collective/blueprint/jsonmigrator/blueprint.py#L67 that needs a patch to work with datafiles and that's why we're asking for a new release since it's now fixed.

And my 0.02c: if @garbas can confirm what you're saying (actually that's true following this commit), I suggest documenting https://github.com/collective/collective.blueprint.jsonmigrator as deprecated in favor of collective.jsonmigrator, in it's README and possibly in it's setup.py as

Development Status :: 7 - Inactive

@djowett
Copy link
Contributor

djowett commented Oct 23, 2015

@idgserpro I agree with your 2c - make the PR & I'll merge it (@thet that's sane right?)

I'm not sure what's the issue with that line... and I wouldn't advise a release to fix an issue without a PR review first. Can you not work from a checked out source rather than 0.2 egg?

@idgserpro
Copy link
Member Author

The issue with that line is explained in the first message of this issue:

AttributeError: 'dict' object has no attribute 'startswith'
Thus I need to patch this line to properly use the json source blueprint (the datafield is a dict but the original code expects a string).

That line is not needed anymore since the datafields blueprint handles that for us.

Yes, we can work from a checked out source, but it's not optimal since it's not an official release from pypi (it's a 0.3.dev0 release that we're using), and more people could benefit from a new release.

Having a new release, you need just a json from collective.jsonify and a transmogrifier.cfg in your policy product like we suggested, and not all the moving parts and patches like we said in the first message.

AFAICT, from this comment, we can wait for @ericof 's opinion as well since he's is the package owner on pypi.

@idgserpro
Copy link
Member Author

@djowett @garbas @thet We still have two opened PR's in collective.blueprint.jsonmigrator. Would it be the case to merge them and make a final release? Or just ask the PR creators to try to redo them here like I said here and here since it will become inactive?

@thet
Copy link
Member

thet commented Oct 23, 2015

i'd prefer to have all activity here. collective.blueprint.jsonmigrator is abandoned and this here is the successor. though, i don't know how much of the functionality is already implemented here.
we should leave a note at collective.blueprint.jsonmigrator about this being the successor.

@ericof
Copy link
Member

ericof commented Oct 25, 2015

Version 0.3 was released on pypi earlier today.

@ericof ericof self-assigned this Oct 25, 2015
@ericof ericof added this to the 0.3 milestone Oct 25, 2015
@ericof ericof closed this as completed Oct 25, 2015
@idgserpro
Copy link
Member Author

Thanks to all involved! It's working flawlessly.

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

5 participants