ploneviewlets

Making member portraits viewable by Anonymous users in Plone 4.1


In Plone 4.1, I'd like to make member portraits (found in portal_memberdata/portraits) viewable by Anonymous users.

Even if I return the correct url to the image in a public View, the image is always protected, and the default one ('defaultUser.png') is returned instead.

How can I accomplish this and display author portraits to Anonymous users inside my viewlets?

Just to clarify:

author.getPersonalPortrait().absolute_url()

will return the correct url to the image. When the image is then fetched by the browser when the view is accessed, the resource is protected.


Solution

  • After a bit of prodding around with pdb, I solved the problem in this way:

    def get_author_image(self, member_id):
        """
        Fetch the author portrait image url accoding to member_id
        """
        mtool = getToolByName(self.context, 'portal_membership')
        mtool.getPersonalPortrait(id=member.id)
    

    The secret is passing the id kwarg. Weird, but it works.

    It wasn't a permission problem, but rather an issue on the way getPersonalPortrait returns the correct url to the image. If you do not specify the id, somehow it won't be able to work out the correct member id, hence fallback to showing the default user image.