• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python management.endInteraction函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中zope.security.management.endInteraction函数的典型用法代码示例。如果您正苦于以下问题:Python endInteraction函数的具体用法?Python endInteraction怎么用?Python endInteraction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了endInteraction函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_write_without_permission_gives_Unauthorized

 def test_write_without_permission_gives_Unauthorized(self):
     distro = self.factory.makeDistribution()
     endInteraction()
     lp = launchpadlib_for("anonymous-access")
     lp_distro = lp.load(api_url(distro))
     lp_distro.active = False
     self.assertRaises(Unauthorized, lp_distro.lp_save)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:7,代码来源:test_distro_webservice.py


示例2: setUp

    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        newInteraction()

        root = functional.getRootFolder()
        setSite(root)
        sm = root.getSiteManager()

        # IIntIds
        root['ids'] = IntIds()
        sm.registerUtility(root['ids'], IIntIds)
        root['ids'].register(root)

        # catalog
        root['catalog'] = Catalog()
        sm.registerUtility(root['catalog'], ICatalog)

        # setup default role
        roles = sm.getUtility(IPortalRoles)
        if 'site.member' not in roles:
            role = PortalRole(title = u'Site Member')
            event.notify(ObjectCreatedEvent(role))

            roles['site.member'] = role
            roleId = role.id
            sm.getUtility(IDefaultPortalRole).roles = [role.id]

        endInteraction()
开发者ID:Zojax,项目名称:QZ3,代码行数:29,代码来源:tests.py


示例3: test_checkPermission

    def test_checkPermission(self):
        from zope.security import checkPermission
        from zope.security.management import setSecurityPolicy
        from zope.security.management import queryInteraction
        from zope.security.management import newInteraction, endInteraction
        from zope.security.interfaces import NoInteraction

        permission = 'zope.Test'
        obj = object()

        class PolicyStub(object):

            def checkPermission(s, p, o,):
                self.assert_(p is permission)
                self.assert_(o is obj)
                self.assert_(s is queryInteraction() or s is interaction)
                return s is interaction

        setSecurityPolicy(PolicyStub)
        newInteraction()
        interaction = queryInteraction()
        self.assertEquals(checkPermission(permission, obj), True)
        
        endInteraction()
        self.assertRaises(NoInteraction, checkPermission, permission, obj)
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:25,代码来源:test_management.py


示例4: publish_and_retry

 def publish_and_retry(self):
     """Publish the request into the response and retry if it
     fails.
     """
     try:
         data = self.publish_and_render_errors()
     except (ConflictError, Retry):
         self.abort()
         self.publication_done = True
         if self.request.supports_retry() and not self.data_sent:
             # If can still retry, and didn't send any data yet, do it.
             logger.info('Conflict, retrying request %s' % (
                     reconstruct_url_from_environ(self.request.environ)))
             endInteraction()
             request = self.request.retry()
             try:
                 publication = self.__class__(
                     self.app, request, self.response)
                 data = publication.publish_and_retry()
                 self.publication_done = publication.publication_done
             finally:
                 request.close()
         else:
             # Otherwise, just render a plain error.
             logger.error('Conflict error for request %s' % (
                     reconstruct_url_from_environ(self.request.environ)))
             self.response.setStatus(503)
             self.response.setBody(RETRY_FAIL_ERROR_TEMPLATE)
             data = self.result()
     return data
开发者ID:infrae,项目名称:infrae.wsgi,代码行数:30,代码来源:publisher.py


示例5: setUp

 def setUp(self):
     super(TestGetBranchTips, self).setUp()
     self.distro = self.factory.makeDistribution()
     series_1 = self.series_1 = self.factory.makeDistroSeries(self.distro)
     series_2 = self.series_2 = self.factory.makeDistroSeries(self.distro)
     source_package = self.factory.makeSourcePackage(distroseries=series_1)
     branch = self.factory.makeBranch(sourcepackage=source_package)
     unofficial_branch = self.factory.makeBranch(
         sourcepackage=source_package)
     registrant = self.factory.makePerson()
     now = datetime.now(pytz.UTC)
     sourcepackagename = self.factory.makeSourcePackageName()
     SeriesSourcePackageBranchSet.new(
         series_1, PackagePublishingPocket.RELEASE, sourcepackagename,
         branch, registrant, now)
     SeriesSourcePackageBranchSet.new(
         series_2, PackagePublishingPocket.RELEASE, sourcepackagename,
         branch, registrant, now)
     self.factory.makeRevisionsForBranch(branch)
     self.branch_name = branch.unique_name
     self.unofficial_branch_name = unofficial_branch.unique_name
     self.branch_last_scanned_id = branch.last_scanned_id
     endInteraction()
     self.lp = launchpadlib_for("anonymous-access")
     self.lp_distro = self.lp.distributions[self.distro.name]
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:25,代码来源:test_distro_webservice.py


示例6: setUp

    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        newInteraction()

        root = functional.getRootFolder()
        setSite(root)
        sm = root.getSiteManager()

        # IIntIds
        root['ids'] = IntIds()
        sm.registerUtility(root['ids'], IIntIds)
        root['ids'].register(root)

        # catalog
        root['catalog'] = Catalog()
        sm.registerUtility(root['catalog'], ICatalog)

        # space
        space = ContentSpace(title=u'Space')
        event.notify(ObjectCreatedEvent(space))
        root['space'] = space

        # people
        people = PersonalSpaceManager(title=u'People')
        event.notify(ObjectCreatedEvent(people))
        root['people'] = people
        sm.registerUtility(root['people'], IPersonalSpaceManager)

        endInteraction()
开发者ID:Zojax,项目名称:zojax.wiki_,代码行数:30,代码来源:tests.py


示例7: setUp

    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        newInteraction()

        root = functional.getRootFolder()
        setSite(root)
        sm = root.getSiteManager()
        sm.getUtility(INameChooserConfiglet).short_url_enabled = True

        # IIntIds
        root["ids"] = IntIds()
        sm.registerUtility(root["ids"], IIntIds)
        root["ids"].register(root)

        # catalog
        root["catalog"] = Catalog()
        sm.registerUtility(root["catalog"], ICatalog)

        # space
        space = ContentSpace(title=u"Space")
        event.notify(ObjectCreatedEvent(space))
        root["space"] = space

        # people
        people = PersonalSpaceManager(title=u"People")
        event.notify(ObjectCreatedEvent(people))
        root["people"] = people
        sm.registerUtility(root["people"], IPersonalSpaceManager)

        endInteraction()
开发者ID:Zojax,项目名称:zojax.poll,代码行数:31,代码来源:tests.py


示例8: test_project_create_cancel

    def test_project_create_cancel(self):
        login(self.portal, testing.SITE_ADMIN)

        challenges = self.portal["challenges"]
        challenges.invokeFactory(id="challenge", type_name="cnrd.Challenge")
        intids = component.getUtility(IIntIds)
        challenge_intid = intids.getId(challenges["challenge"])

        add_view = self.portal.restrictedTraverse("workspaces/++add++cnrd.Project")
        add_view.request.form["challenge"] = str(challenge_intid)
        add_view.update()

        edit_location = add_view.request.response.getHeader('Location')
        edit_path = add_view.request.physicalPathFromURL(edit_location)

        self.assertEqual(edit_path[-2:], ['project-draft', 'edit'])
        self.assertIn(edit_path[-2], self.portal["workspaces"])

        edit_path[-1] = "@@" + edit_path[-1]
        edit_view = self.portal.restrictedTraverse(edit_path)
        edit_view.request['SESSION'] = {}
        edit_view.request.form = { "form.buttons.cancel": 1 }
        newInteraction()
        edit_view.update()
        endInteraction()

        location = edit_view.request.response.getHeader('Location')
        path = add_view.request.physicalPathFromURL(location)

        self.assertEqual(path[-2:], ['challenges', 'challenge'])
        self.assertNotIn(edit_path[-2], self.portal["workspaces"])
开发者ID:ixds,项目名称:plone-virtualcenter,代码行数:31,代码来源:test_project.py


示例9: setUp

    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        newInteraction()

        root = functional.getRootFolder()
        setSite(root)
        sm = root.getSiteManager()
        sm.getUtility(INameChooserConfiglet).short_url_enabled = True

        # IIntIds
        root['ids'] = IntIds()
        sm.registerUtility(root['ids'], IIntIds)
        root['ids'].register(root)

        # catalog
        root['catalog'] = Catalog()
        sm.registerUtility(root['catalog'], ICatalog)

        setattr(root, 'principalId', 'zope.mgr')
        # space
        space = ContentSpace(title=u'Space')
        event.notify(ObjectCreatedEvent(space))
        root['space'] = space

        setattr(root, 'principal', getUtility(IAuthentication).getPrincipal('zope.mgr'))
        # people
        people = PersonalSpaceManager(title=u'People')
        event.notify(ObjectCreatedEvent(people))
        root['people'] = people
        sm.registerUtility(root['people'], IPersonalSpaceManager)

        endInteraction()
开发者ID:Zojax,项目名称:zojax.personal.project,代码行数:33,代码来源:tests.py


示例10: run_with_login

def run_with_login(login_id, function, *args, **kwargs):
    """Run 'function' logged in with 'login_id'.

    The first argument passed to 'function' will be the Launchpad
    `Person` object corresponding to 'login_id'.

    The exception is when the requesting login ID is `LAUNCHPAD_SERVICES`. In
    that case, we'll pass through the `LAUNCHPAD_SERVICES` variable and the
    method will do whatever security proxy hackery is required to provide read
    privileges to the Launchpad services.
    """
    if login_id == LAUNCHPAD_SERVICES or login_id == LAUNCHPAD_ANONYMOUS:
        # Don't pass in an actual user. Instead pass in LAUNCHPAD_SERVICES
        # and expect `function` to use `removeSecurityProxy` or similar.
        return function(login_id, *args, **kwargs)
    if isinstance(login_id, basestring):
        requester = getUtility(IPersonSet).getByName(login_id)
    else:
        requester = getUtility(IPersonSet).get(login_id)
    if requester is None:
        raise NotFoundError("No person with id %s." % login_id)
    setupInteractionForPerson(requester)
    try:
        return function(requester, *args, **kwargs)
    finally:
        endInteraction()
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:26,代码来源:codehosting.py


示例11: publish

def publish(request, module_name,
            _get_module_info=get_module_info,  # only for testing
           ):
    (bobo_before,
     bobo_after,
     object,
     realm,
     debug_mode,
     err_hook,
     validated_hook,
     transactions_manager,
    ) = _get_module_info(module_name)

    notify(PubStart(request))
    newInteraction()
    try:
        request.processInputs()
        response = request.response

        if bobo_after is not None:
            response.after_list += (bobo_after,)

        if debug_mode:
            response.debug_mode = debug_mode

        if realm and not request.get('REMOTE_USER', None):
            response.realm = realm

        if bobo_before is not None:
            bobo_before()

        # Get the path list.
        # According to RFC1738 a trailing space in the path is valid.
        path = request.get('PATH_INFO')

        request['PARENTS'] = [object]
        object = request.traverse(path, validated_hook=validated_hook)
        notify(PubAfterTraversal(request))

        if transactions_manager:
            transactions_manager.recordMetaData(object, request)

        result = mapply(object,
                        request.args,
                        request,
                        call_object,
                        1,
                        missing_name,
                        dont_publish_class,
                        request,
                        bind=1,
                        )

        if result is not response:
            response.setBody(result)
    finally:
        endInteraction()

    notify(PubBeforeCommit(request))
    return response
开发者ID:asajohnston,项目名称:Zope,代码行数:60,代码来源:WSGIPublisher.py


示例12: wrapper

 def wrapper(*a, **kw):
     from zope.security.management import newInteraction
     from zope.security.management import endInteraction
     newInteraction(SystemConfigurationParticipation())
     result = func(*a, **kw)
     endInteraction()
     return result
开发者ID:avnik,项目名称:nanozope,代码行数:7,代码来源:bootstrap.py


示例13: setUpDebug

def setUpDebug(test):
    placelesssetup.setUp(test)
    test.real_stderr = sys.stderr
    test.real_argv = list(sys.argv)
    test.olddir = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__file__), 'testdata'))
    from zope.security.management import endInteraction
    endInteraction()
开发者ID:grodniewicz,项目名称:oship,代码行数:8,代码来源:tests.py


示例14: test_endInteraction

    def test_endInteraction(self):
        from zope.security.management import endInteraction
        from zope.security.management import newInteraction
        from zope.security.management import queryInteraction

        newInteraction()
        endInteraction()
        self.assertEqual(queryInteraction(), None)
开发者ID:felixonmars,项目名称:zope.security,代码行数:8,代码来源:test_management.py


示例15: setUp

 def setUp(self):
     super(DebugLayer, self).setUp()
     self.stderr = sys.stderr
     self.argv = list(sys.argv)
     self.olddir = os.getcwd()
     os.chdir(os.path.join(os.path.dirname(__file__), 'testdata'))
     from zope.security.management import endInteraction
     endInteraction()
开发者ID:zopefoundation,项目名称:zope.app.appsetup,代码行数:8,代码来源:tests.py


示例16: test_distroseries_architectures_anonymous

 def test_distroseries_architectures_anonymous(self):
     """Test anonymous DistroArchSeries API Access."""
     distroseries = self._makeDistroArchSeries()
     endInteraction()
     launchpad = launchpadlib_for('test', person=None, version='devel')
     ws_distroseries = ws_object(launchpad, distroseries)
     # Note, we test the length of architectures.entries, not
     # architectures due to the removal of the entries by lazr
     self.assertEqual(1, len(ws_distroseries.architectures.entries))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:9,代码来源:test_distroarchseries_webservice.py


示例17: _call_manage_main

 def _call_manage_main(self):
     self.setRoles(['Manager'])
     # temporaryPlacelessSetUp insists in creating an interaction
     # which the WSGI publisher does not expect.
     endInteraction()
     response = self.publish(
         '/{0.folder_name}/manage_main'.format(Testing.ZopeTestCase),
         basic=basic_auth)
     return str(response)
开发者ID:dhavlik,项目名称:Zope,代码行数:9,代码来源:tests.py


示例18: setUp

    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        newInteraction()

        def fake_utcnow(self):
            return datetime.datetime(2015, 7, 30, 8, 0, 0)
        curse(datetime.datetime, 'utcnow', classmethod(fake_utcnow))

        root = functional.getRootFolder()
        setSite(root)
        sm = root.getSiteManager()

        # IIntIds
        root['intids'] = IntIds()
        sm.registerUtility(root['intids'], IIntIds)
        root['intids'].register(root)

        # catalog
        root['catalog'] = Catalog()
        sm.registerUtility(root['catalog'], ICatalog)

        # PluggableAuthentication
        pau = PluggableAuthentication(u'')
        event.notify(ObjectCreatedEvent(pau))
        sm[u'auth'] = pau
        sm.registerUtility(pau, IAuthentication)

        # Credentials Plugin
        defaultCreds.install()
        defaultCreds.activate()

        # people
        people = PersonalSpaceManager(title=u'People')
        event.notify(ObjectCreatedEvent(people))
        root['people'] = people
        sm.registerUtility(root['people'], IPersonalSpaceManager)

        user = sm.getUtility(IAuthentication).getPrincipal('zope.mgr')
        people.assignPersonalSpace(user)

        user = sm.getUtility(IAuthentication).getPrincipal('zope.user')
        people.assignPersonalSpace(user)

        # default content
        content = Content(u'Content1', u'Some Content1')
        event.notify(ObjectCreatedEvent(content))
        IOwnership(content).ownerId = 'zope.user'
        root['content1'] = content

        content = Content(u'Content2', u'Some Content2')
        event.notify(ObjectCreatedEvent(content))
        IOwnership(content).ownerId = 'zope.user'
        root['content2'] = content

        endInteraction()
开发者ID:Zojax,项目名称:zojax.acknowledgement,代码行数:56,代码来源:tests.py


示例19: transaction_pubevents

def transaction_pubevents(request, response, tm=transaction.manager):
    try:
        setDefaultSkin(request)
        newInteraction()
        tm.begin()
        notify(pubevents.PubStart(request))

        yield

        notify(pubevents.PubBeforeCommit(request))
        if tm.isDoomed():
            tm.abort()
        else:
            tm.commit()
        notify(pubevents.PubSuccess(request))
    except Exception as exc:
        # Normalize HTTP exceptions
        # (For example turn zope.publisher NotFound into zExceptions NotFound)
        exc_type, _ = upgradeException(exc.__class__, None)
        if not isinstance(exc, exc_type):
            exc = exc_type(str(exc))

        # Create new exc_info with the upgraded exception.
        exc_info = (exc_type, exc, sys.exc_info()[2])

        try:
            # Raise exception from app if handle-errors is False
            # (set by zope.testbrowser in some cases)
            if request.environ.get('x-wsgiorg.throw_errors', False):
                reraise(*exc_info)

            if isinstance(exc, Unauthorized):
                # _unauthorized modifies the response in-place. If this hook
                # is used, an exception view for Unauthorized has to merge
                # the state of the response and the exception instance.
                exc.setRealm(response.realm)
                response._unauthorized()
                response.setStatus(exc.getStatus())

            # Handle exception view
            exc_view_created = _exc_view_created_response(
                exc, request, response)

            notify(pubevents.PubBeforeAbort(
                request, exc_info, request.supports_retry()))
            tm.abort()
            notify(pubevents.PubFailure(
                request, exc_info, request.supports_retry()))

            if not (exc_view_created or isinstance(exc, Unauthorized)):
                reraise(*exc_info)
        finally:
            # Avoid traceback / exception reference cycle.
            del exc, exc_info
    finally:
        endInteraction()
开发者ID:dhavlik,项目名称:Zope,代码行数:56,代码来源:WSGIPublisher.py


示例20: _get_bug_for_user

    def _get_bug_for_user(self, user=None):
        """Convenience function to get the api bug reference."""
        endInteraction()
        if user is not None:
            lp = launchpadlib_for("test", user)
        else:
            lp = launchpadlib_for("test")

        bug_entry = lp.load('/bugs/%s/' % self.bug.id)
        return bug_entry
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:10,代码来源:test_bug_messages_webservice.py



注:本文中的zope.security.management.endInteraction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap