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

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

Open
djowett opened this issue Jul 23, 2014 · 2 comments
Open

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

djowett opened this issue Jul 23, 2014 · 2 comments

Comments

@djowett
Copy link
Contributor

djowett commented Jul 23, 2014

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
Copy link
Contributor

garbas commented Jul 29, 2014

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
Copy link

mamoep commented Mar 20, 2018

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]))

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