def afterSetUp(self): self.installDependencies() self.createBasicSetup() self.container._clear() self.user_member = User('testmember', '', ('Member', ), []).__of__(self.portal.acl_users) self.user_manager = User('testmanager', '', ('Manager', ), []).__of__(self.portal.acl_users) self.user_anonymous = nobody.__of__(self.portal.acl_users) self.container.atse_registerObject(self.target1)
def bbox_value(obj, **kw): # Execute this as 'Anonymous' try: sm = getSecurityManager() newSecurityManager(None, nobody.__of__(obj.acl_users)) ex = IExtent(obj) return tuple(shape(ex.extent).bounds) except: raise AttributeError finally: setSecurityManager(sm)
def reprPt_value(obj, **kw): # Execute this as 'Anonymous' try: sm = getSecurityManager() newSecurityManager(None, nobody.__of__(obj.acl_users)) pt = IRepresentativePoint(obj) return pt.coords, pt.precision except: raise AttributeError finally: setSecurityManager(sm)
def zgeo_geometry_value(obj, **kw): # Execute this as 'Anonymous' try: sm = getSecurityManager() newSecurityManager(None, nobody.__of__(obj.acl_users)) ex = IExtent(obj) return ex.extent except: raise AttributeError finally: setSecurityManager(sm)
def _createAnonymousUser(self, plugins): """ Allow IAnonymousUserFactoryPlugins to create or fall back. """ factories = plugins.listPlugins(IAnonymousUserFactoryPlugin) for factory_id, factory in factories: anon = factory.createAnonymousUser() if anon is not None: return anon.__of__(self) return nobody.__of__(self)
def _createAnonymousUser( self, plugins ): """ Allow IAnonymousUserFactoryPlugins to create or fall back. """ factories = plugins.listPlugins( IAnonymousUserFactoryPlugin ) for factory_id, factory in factories: anon = factory.createAnonymousUser() if anon is not None: return anon.__of__( self ) return nobody.__of__( self )
def representative_point(obj): # Get a representative point as Anonymous.""" sm = getSecurityManager() try: newSecurityManager(None, nobody.__of__(obj.acl_users)) pt = IRepresentativePoint(obj) res = {'precision': pt.precision, 'coords': pt.coords} except NotLocatedError: res = {'precision': 'unlocated', 'coords': None} except: log.warn("Failed to adapt %s in 'representative_point'", obj) res = None finally: setSecurityManager(sm) return res
def extent(obj): # "unlocated", "rough", "related", "precise" # Executed as anonymous to keep unpublished data out sm = getSecurityManager() try: newSecurityManager(None, nobody.__of__(obj.acl_users)) ex = IExtent(obj) res = {'extent': ex.extent, 'precision': ex.precision} except NotLocatedError: res = {'extent': None, 'precision': 'unlocated'} except: log.warn("Failed to adapt %s in 'location_precision'", obj) res = None finally: setSecurityManager(sm) return res
def anonymous_user(site): sm = getSecurityManager() newSecurityManager(None, nobody.__of__(site.acl_users)) yield setSecurityManager(sm)