Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9188969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:08:23+00:00 2026-06-17T20:08:23+00:00

I have a problem where I need to be able to make custom content

  • 0

I have a problem where I need to be able to make custom content accessible for search and retrieval via portal_catalog by anonymous users but not viewable by them.

I used custom content types and a custom workflow, what I’m getting is most likely a permission issue. I defined a custom workflow through ZMI -> portal_workflow and then exported it into source code as an XML definition. I set the permissions for anonymous users as ‘Access Content Information’ but not ‘View’. Note that ‘active’ in the code snippet is a workflow state that has that permission enabled — sales_workflow

Brain lookup works for ‘Manager’ role, but when the role is switched to ‘Anonymous’, catalog returns an empty list.

import unittest2 as unittest


from . import INTEGRATION_TESTING
from AccessControl import getSecurityManager

from plone.app.testing import setRoles, logout
from plone.app.testing import TEST_USER_ID

from Products.CMFCore.utils import getToolByName

def drop_to_anonymous(self):
    """
    Drop site roles to anonymous user only.
    Note this is a class method and not a function
    assign this method as a class member and then call it
    """
    logout()
    setRoles(self.portal, TEST_USER_ID, ['Anonymous'])
    user = getSecurityManager().getUser()
    roles =  user.getRolesInContext(self.portal)
    self.assertListEqual(['Anonymous'], roles)

class TestSalesRepWorkflow(unittest.TestCase):
    layer = INTEGRATION_TESTING
    drop_to_anonymous = drop_to_anonymous
    def setUp(self):
        self.portal = self.layer['portal']
        self.wftool = getToolByName(self.portal, 'portal_workflow')
        self.catalog = getToolByName(self.portal, 'portal_catalog')
    def test_workflow_lookup_anon(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        self.portal.invokeFactory(
                                'CustomProduct',
                                'prod1',
                                title="Product 1"
                                )
        prod1 = self.portal['prod1']
        self.wftool.doActionFor(prod1, action='activate')
        review_state = self.wftool.getInfoFor(prod1, 'review_state')
        prod1.reindexObject()
        self.assertEqual('active', review_state)
        lookup = self.catalog(portal_type='CustomProduct', Title='Product 1',
                            review_state='active')
        #This test passes with managerial permissions
        self.assertEqual(len(lookup), 1)
        #Repeat the same test in 'Anonymous' role
        self.drop_to_anonymous()
        lookup1 = self.catalog(portal_type='CustomProduct', Title='Product 1',
                            review_state='active')
        #When dropped to anonymous role, the test fails, 
        #lookup returns an empty list
        self.assertEqual(len(lookup1), 1)

Is there a way to fix this without drastically reworking permissions?

Using unrestrictedSearchResults seems to fix the search, but whenever I attempt to run ‘getObject’ on a brain, the following error gets raised:

Unauthorized: You are not allowed to access 'XXX' in this context
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:08:24+00:00Added an answer on June 17, 2026 at 8:08 pm

    Your active state needs to give the View permission to Anonymous. Currently it is restricted to these roles:

    <state state_id="active" title="">
     <!-- other information elided here --> 
     <permission-map name="View" acquired="False">
       <permission-role>Manager</permission-role>
       <permission-role>Owner</permission-role>
       <permission-role>Reviewer</permission-role>
       <permission-role>SalesRep</permission-role>
       <permission-role>Site Administrator</permission-role>
      </permission-map>
    

    Without the View permission anonymous cannot see your objects even when given the active state, nor can they be found in the catalog by that user.

    You can override this behaviour of the catalog by using the .unrestrictedSearchResults() method of the catalog:

    lookup1 = self.catalog.unrestrictedSearchResults(
        portal_type='SalesProduct', Title='Product 1', review_state='active')
    

    This method cannot be used from restricted code.

    The returned brain objects are perfectly accessible by anonymous users, but you cannot use the getObject() method on them because that’ll use the current user’s permissions to traverse to it. If you need to get the actual object from the brain, there is again a special, private method to get to the actual object without those restrictions, called ._unrestrictedGetObject():

    obj = brain._unrestrictedGetObject()
    

    This method is, once again, only available to unrestricted code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem i need to convert from my Array structure to std::vector<int> ...
I have a problem where I need to split an input string into possible
I have a problem where I need to remove all code and triggers from
I have the following problem: I need to use XSLFO to generate a 2-column
I have the next problem: I need to process only 1 request at a
OSX 10.7, XCode 4. I have a small problem: I need to push back
I have a problem with Matlab - I need to do the following :
I have a problem with Json formating returned from .ASMX I need to return
I have a problem to test my non activity-class which need the context of
I have a problem, I need to change body of method when this class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.