Ownership of content

Description

Programmatically manipulate Plone content item's ownership

Introduction

Each content item has an owner user.

Owned item instances are of subclass of AccessControl.Owned

Getting the owner of the item

Example:

# Returns PropertiedUser for Zope admin
# Returns PloneUser for normal users object
context.getOwner()

Changing ownership of content

You can use AccessControl.Owner.changeOwnership:

changeOwnership(self, user, recursive=0)

User is PropertiedUser object.

Example:

# Get the user handle from member data object
user = member.getUser()

# Make the member owner of his home folder
home_folder.changeOwnership(user, recursive=False)
home_folder.reindexObjectSecurity()

Warning

Could not get this to work. Use local roles instead.

Example how to add ownership for additional user using local roles:

home_folder.manage_setLocalRoles(username, ["Owner",])
home_folder.reindexObjectSecurity()

Note

This does not update Dublin Core metadata fields like creator.

Contributors

Contributors is an automatically managed list where persons, who have been editing in the past, real names are listed. Contributors data is available as Python list of real names.

Note

Contributors does not store user references, because one might want to maintain contributor data even after the user has been deleted.

Some sample code:

def format_contributors(contribs):
        """
        @return: String of comma separated list of all contributors
        """

        if len(contribs) == 0:
            return None

        return ", ".join(contribs)

 data = {
        "contributors" : format_contributors(obj.Contributors()),
 }
<span tal:condition="o/contributors">
    <span tal:replace="o/contributors">Jim Smith, Jane Doe</span>
</span>



Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Go to Ownership of content on GitHub.
  2. Press Fork and edit this file button.
  3. Edit file contents using GitHub's text editor in your web browserm
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on Github.

For basic information about updating this manual and Sphinx format please see Writing and updating the manual guide.