Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(58)  |  Call(53)  |  Derive(0)  |  Import(5)

        def guarded_hasattr(object, name):
    try:
        guarded_getattr(object, name)
    except (AttributeError, Unauthorized):
        return 0
    return 1
        


src/z/o/Zope2-2.13.22/src/Products/Five/viewlet/manager.py   Zope2(Download)
 
from Acquisition import aq_base
from AccessControl.ZopeGuards import guarded_hasattr
import zope.interface
import zope.security
        # If the viewlet cannot be accessed, then raise an
        # unauthorized error
        if not guarded_hasattr(viewlet, 'render'):
            raise zope.security.interfaces.Unauthorized(
                'You are not authorized to access the provider '
        # security.
        for name, viewlet in viewlets:
            if guarded_hasattr(viewlet, 'render'):
                results.append((name, viewlet))
        return results

src/z/o/Zope-HEAD/src/Products/Five/viewlet/manager.py   Zope(Download)
 
from Acquisition import aq_base
from AccessControl.ZopeGuards import guarded_hasattr
import zope.interface
import zope.security
        # If the viewlet cannot be accessed, then raise an
        # unauthorized error
        if not guarded_hasattr(viewlet, 'render'):
            raise zope.security.interfaces.Unauthorized(
                'You are not authorized to access the provider '
        # security.
        for name, viewlet in viewlets:
            if guarded_hasattr(viewlet, 'render'):
                results.append((name, viewlet))
        return results

src/p/l/plone.app.viewletmanager-2.0.5/plone/app/viewletmanager/manager.py   plone.app.viewletmanager(Download)
from Acquisition import aq_base
from Acquisition.interfaces import IAcquirer
from AccessControl.ZopeGuards import guarded_hasattr
from Products.Five import BrowserView
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
            if IAcquirer.providedBy(viewlet):
                viewlet = viewlet.__of__(viewlet.context)
            if name not in hidden and guarded_hasattr(viewlet, 'render'):
                results.append((name, viewlet))
        return results
                           'hide_url': query_tmpl % urlencode({'hide': viewlet_id})}
 
                if guarded_hasattr(viewlet, 'render'):
                    viewlet.update()
                    options['content'] = viewlet.render()

src/e/r/erp5-HEAD/product/ERP5Type/tests/testERP5Type.py   erp5(Download)
from AccessControl import getSecurityManager
from AccessControl import Unauthorized
from AccessControl.ZopeGuards import guarded_getattr, guarded_hasattr
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type.tests.utils import removeZODBPythonScript
      obj = self.getPersonModule().newContent(portal_type='Person')
 
      self.assertTrue(guarded_hasattr(obj, 'setFooBar'))
      self.assertTrue(guarded_hasattr(obj, 'getFooBar'))
 
      # setter is protected by default with modify portal content
      obj.manage_permission(Permissions.ModifyPortalContent, [], 0)
      self.assertFalse(guarded_hasattr(obj, 'setFooBar'))
      self.assertTrue(guarded_hasattr(obj, 'getFooBar'))

src/e/r/erp5-HEAD/product/ERP5Form/tests/testPreferences.py   erp5(Download)
from AccessControl.SecurityManagement import getSecurityManager
from zExceptions import Unauthorized
from AccessControl.ZopeGuards import guarded_hasattr
from DateTime import DateTime