collective / collective.jsonmigrator

JSON based migrations for Plone
GNU General Public License v2.0
8 stars 21 forks source link

Comments requested on Owner blueprint (doesn't seem to work) #7

Open djowett opened 10 years ago

djowett commented 10 years ago

I'd appreciate comments on the following.

After investigating whether the owner blueprint is really working (it wasn't on my latest project), I found that owner.py and the owner blueprint documentation both expect item['_owner'] to be a list, whereas this commit in collective.jsonify (in 2011) sets what will be item['_owner'] to a string.

Did a matching commit to collective.jsonmigrator get lost at that stage? Has anyone seen the owner blueprint working since? I'm happy to write a fix, but want to know if I'm breaking anything that works.

And (in case folk think I'm moaning) I still really appreciate the product and (esp @garbas) your work on it.

garbas commented 10 years ago

Quoting Daniel Jowett (2014-07-23 12:33:00)

I'd appreciate comments on the following.

After investigating whether the owner blueprint is really working (it wasn't on my latest project), I found that owner.py and the owner blueprint documentation both expect item['_owner'] to be a list, whereas this commit in collective.jsonify (in 2011) sets what will be item['_owner'] to a string.

Did a matching commit to collective.jsonmigrator get lost at that stage? Has anyone seen the owner blueprint working since? I'm happy to write a fix, but want to know if I'm breaking anything that works.

And (in case folk think I'm moaning) I still really appreciate the product and (esp @garbas) your work on it.

feel free to contribute.

Rok Garbas - http://www.garbas.si

mamoep commented 6 years ago

I just ran into the same issue. Here is a diff for the owner.py which solves it and also supports Dexterity.

12a13,17
> try:
>     from plone.dexterity.interfaces import IDexterityContent
>     dexterity_available = True
> except:
>     dexterity_available = False
28a34
>
39a46
>
51c58
<             if item[ownerkey] is None or len(item[ownerkey]) != 2:
---
>             if item[ownerkey] is None:
63c70,71
<             if not IBaseObject.providedBy(obj):
---
>             if not (IBaseObject.providedBy(obj) or (dexterity_available and IDexterityContent.providedBy(obj))):
>                 yield item
66,85c74,85
<             if item[ownerkey][0] and item[ownerkey][1]:
<                 try:
<                     obj.changeOwnership(
<                         self.memtool.getMemberById(item[ownerkey][1]))
<                 except Exception as e:
<                     raise Exception('ERROR: %s SETTING OWNERSHIP TO %s' %
<                                     (str(e), item[pathkey]))
<
<                 try:
<                     obj.manage_setLocalRoles(item[ownerkey][1], ['Owner'])
<                 except Exception as e:
<                     raise Exception('ERROR: %s SETTING OWNERSHIP2 TO %s' %
<                                     (str(e), item[pathkey]))
<
<             elif not item[ownerkey][0] and item[ownerkey][1]:
<                 try:
<                     obj._owner = item[ownerkey][1]
<                 except Exception as e:
<                     raise Exception('ERROR: %s SETTING __OWNERSHIP TO %s' %
<                                     (str(e), item[pathkey]))
---
>             try:
>                 obj.changeOwnership(
>                     self.memtool.getMemberById(item[ownerkey]))
>             except Exception as e:
>                 raise Exception('ERROR: %s SETTING OWNERSHIP TO %s' %
>                                 (str(e), item[pathkey]))
>
>             try:
>                 obj.manage_setLocalRoles(item[ownerkey], ['Owner'])
>             except Exception as e:
>                 raise Exception('ERROR: %s SETTING OWNERSHIP2 TO %s' %
>                                 (str(e), item[pathkey]))