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

Python publish.mapply函数代码示例

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

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



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

示例1: testClass

    def testClass(self):
        values = {"a": 2, "b": 3, "c": 5}

        class c(object):
            a = 3

            def __call__(self, b, c=4):
                return "%d%d%d" % (self.a, b, c)

            compute = __call__

        cc = c()
        v = mapply(cc, (), values)
        self.failUnlessEqual(v, "335")

        del values["c"]
        v = mapply(cc.compute, (), values)
        self.failUnlessEqual(v, "334")

        class c2:
            """Must be a classic class."""

        c2inst = c2()
        c2inst.__call__ = cc
        v = mapply(c2inst, (), values)
        self.failUnlessEqual(v, "334")
开发者ID:wpjunior,项目名称:proled,代码行数:26,代码来源:test_mapply.py


示例2: __call__

 def __call__(self):
     mapply(self.update, (), self.request)
     agenda_recente = self.agenda_recente()
     if agenda_recente and not self.editable:
         return agenda_recente.restrictedTraverse('@@view')()
     else:
         return super(AgendaView, self).__call__()
开发者ID:plonegovbr,项目名称:brasil.gov.agenda,代码行数:7,代码来源:agenda.py


示例3: __call__

 def __call__(self):
     self.layout = self._get_layout()
     mapply(self.update, (), self.request)
     if self.request.response.getStatus() in (302, 303):
         # A redirect was triggered somewhere in update().  Don't
         # continue rendering the template or doing anything else.
         return
     return self.layout(self)
开发者ID:jean,项目名称:grokcore.layout,代码行数:8,代码来源:components.py


示例4: testMethod

    def testMethod(self):
        def compute(a,b,c=4):
            return '%d%d%d' % (a, b, c)
        values = {'a':2, 'b':3, 'c':5}
        v = mapply(compute, (), values)
        self.failUnlessEqual(v, '235')

        v = mapply(compute, (7,), values)
        self.failUnlessEqual(v, '735')
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:9,代码来源:test_mapply.py


示例5: __call__

 def __call__(self):
     mapply(self.update, (), self.request)
     if self.request.response.getStatus() in (302, 303):
         # A redirect was triggered somewhere in update().  Don't
         # continue rendering the template or doing anything else.
         return
     self.layout = zope.component.getMultiAdapter(
         (self.request, self.context), ILayout)
     return self.layout(self)
开发者ID:grodniewicz,项目名称:oship,代码行数:9,代码来源:components.py


示例6: testMethod

    def testMethod(self):
        def compute(a, b, c=4):
            return "%d%d%d" % (a, b, c)

        values = {"a": 2, "b": 3, "c": 5}
        v = mapply(compute, (), values)
        self.assertEqual(v, "235")

        v = mapply(compute, (7,), values)
        self.assertEqual(v, "735")
开发者ID:pombredanne,项目名称:zope.publisher,代码行数:10,代码来源:test_mapply.py


示例7: __call__

    def __call__(self):
        mapply(self.update, (), self.request)
        if self.request.response.getStatus() in (302, 303):
            # A redirect was triggered somewhere in update().  Don't
            # continue rendering the template or doing anything else.
            return

        template = getattr(self, 'template', None)
        if template is not None:
            return self._render_template()
        return mapply(self.render, (), self.request)
开发者ID:grodniewicz,项目名称:oship,代码行数:11,代码来源:components.py


示例8: __call__

    def __call__(self):
        mapply(self.update, (), self.request)
        if self.response.getStatus() in (302, 303):
            # A redirect was triggered somewhere in update().  Don't
            # continue processing the form
            return

        self.updateForm()
        if self.response.getStatus() in (302, 303):
            return

        return self.render()
开发者ID:thefunny42,项目名称:Zeam-Form,代码行数:12,代码来源:form.py


示例9: testAncientMethod

 def testAncientMethod(self):
     # Before Python 2.6, methods did not have __func__ and __code__.
     # They had im_func and func_code instead.
     # This may still be the case for RestrictedPython scripts.
     # Pretend a method that accepts one argument and one keyword argument.
     # The default value for the keyword argument is given as a tuple.
     method = AncientMethod('7 * %d + %d', (0,))
     values = {}
     v = mapply(method, (6,), values)
     self.assertEqual(v, 42)
     v = mapply(method, (5, 4), values)
     self.assertEqual(v, 39)
开发者ID:minddistrict,项目名称:zope.publisher,代码行数:12,代码来源:test_mapply.py


示例10: __call__

    def __call__(self):
        mapply(self.update, (), self.request)
        if self.request.response.getStatus() in (302, 303):
            # A redirect was triggered somewhere in update().  Don't
            # continue processing the form
            return
        self.updateForm()
        if self.request.response.getStatus() in (302, 303):
            return

        self.layout = getMultiAdapter(
            (self.request, self.context), ILayout)
        return self.layout(self)
开发者ID:prinzdezibel,项目名称:p2.datashackle.management,代码行数:13,代码来源:base.py


示例11: testClass

    def testClass(self):
        values = {'a':2, 'b':3, 'c':5}
        class c(object):
            a = 3
            def __call__(self, b, c=4):
                return '%d%d%d' % (self.a, b, c)
            compute = __call__
        cc = c()
        v = mapply(cc, (), values)
        self.assertEqual(v, '335')

        del values['c']
        v = mapply(cc.compute, (), values)
        self.assertEqual(v, '334')
开发者ID:minddistrict,项目名称:zope.publisher,代码行数:14,代码来源:test_mapply.py


示例12: __call__

    def __call__(self):
        __traceback_supplement__ = (ErrorSupplement, self)

        layout_factory = component.getMultiAdapter(
            (self.request, self.context,), ILayoutFactory)
        self.layout = layout_factory(self)

        mapply(self.update, (), self.request)

        if self.request.response.getStatus() in (302, 303):
            # A redirect was triggered somewhere in update().  Don't
            # continue rendering the template or doing anything else.
            return

        return self.layout(self)
开发者ID:infrae,项目名称:infrae.layout,代码行数:15,代码来源:components.py


示例13: __call__

    def __call__(self):
        convert_request_form_to_unicode(self.request.form)

        self.layout = component.getMultiAdapter(
            (self.request, self.context), ILayout)

        mapply(self.update, (), self.request)
        if self.request.response.getStatus() in (302, 303):
            # A redirect was triggered somewhere in update(). Don't
            # continue processing the form
            return

        self.updateForm()
        if self.request.response.getStatus() in (302, 303):
            return

        return self.layout(self)
开发者ID:silvacms,项目名称:zeam.form.silva,代码行数:17,代码来源:public.py


示例14: callObject

 def callObject(self, request, ob):
     # Exception handling, dont try to call request.method
     orig = ob
     #if not IHTTPException.providedBy(ob):
     #    ob = getattr(ob, request.method, None)
     #    if ob is None:
     #        raise MethodNotAllowed(orig, request)
     return mapply(ob, request.getPositionalArguments(), request)
开发者ID:avnik,项目名称:nanozope,代码行数:8,代码来源:publisher.py


示例15: callObject

    def callObject(self, request, ob):
        """Call the object, returning the result.

        For GET/POST this means calling it, but for other methods
        (including those of WebDAV and FTP) this might mean invoking
        a method of an adapter.
        """
        from zope.publisher.publish import mapply
        return mapply(ob, request.getPositionalArguments(), request)
开发者ID:grodniewicz,项目名称:oship,代码行数:9,代码来源:test_vhosting.py


示例16: testClass

    def testClass(self):
        values = {"a": 2, "b": 3, "c": 5}

        class c(object):
            a = 3

            def __call__(self, b, c=4):
                return "%d%d%d" % (self.a, b, c)

            compute = __call__

        cc = c()
        v = mapply(cc, (), values)
        self.assertEqual(v, "335")

        del values["c"]
        v = mapply(cc.compute, (), values)
        self.assertEqual(v, "334")
开发者ID:pombredanne,项目名称:zope.publisher,代码行数:18,代码来源:test_mapply.py


示例17: callObject

    def callObject(self, request, ob):
        """See `zope.publisher.interfaces.IPublication`.

        Our implementation make sure that no result is returned on
        redirect.

        It also sets the launchpad.userid and launchpad.pageid WSGI
        environment variables.
        """
        request._publicationticks_start = tickcount.tickcount()
        if request.response.getStatus() in [301, 302, 303, 307]:
            return ''

        request.setInWSGIEnvironment(
            'launchpad.userid', request.principal.id)

        # The view may be security proxied
        view = removeSecurityProxy(ob)
        # It's possible that the view is a bound method.
        view = getattr(view, 'im_self', view)
        context = removeSecurityProxy(getattr(view, 'context', None))
        pageid = self.constructPageID(view, context)
        request.setInWSGIEnvironment('launchpad.pageid', pageid)
        # And spit the pageid out to our tracelog.
        tracelog(request, 'p', pageid)

        # For status URLs, where we really don't want to have any DB access
        # at all, ensure that all flag lookups will stop early.
        if pageid in (
            'RootObject:OpStats', 'RootObject:+opstats',
            'RootObject:+haproxy'):
            request.features = NullFeatureController()
            features.install_feature_controller(request.features)

        # Calculate the hard timeout: needed because featureflags can be used
        # to control the hard timeout, and they trigger DB access, but our
        # DB tracers are not safe for reentrant use, so we must do this
        # outside of the SQL stack. We must also do it after traversal so that
        # the view is known and can be used in scope resolution. As we
        # actually stash the pageid after afterTraversal, we need to do this
        # even later.
        da.set_permit_timeout_from_features(True)
        da._get_request_timeout()

        if isinstance(removeSecurityProxy(ob), METHOD_WRAPPER_TYPE):
            # this is a direct call on a C-defined method such as __repr__ or
            # dict.__setitem__.  Apparently publishing this is possible and
            # acceptable, at least in the case of
            # lp.services.webapp.servers.PrivateXMLRPCPublication.
            # mapply cannot handle these methods because it cannot introspect
            # them.  We'll just call them directly.
            return ob(*request.getPositionalArguments())

        return mapply(ob, request.getPositionalArguments(), request)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:54,代码来源:publication.py


示例18: callObject

    def callObject(self, request, ob):
        if request.method == 'GET':
            orig = removeAllProxies(ob)
            if type(orig) is MethodType:
                strategy = ICacheStrategy(orig.im_self, None)
            else:
                strategy = ICacheStrategy(orig, None)

            if strategy is not None:
                strategy = strategy.__bind__(request)
                if not strategy.isModified():
                    request.response.setStatus(304)
                    strategy.setNotModifiedHeaders()
                    return ''

                result = mapply(ob, request.getPositionalArguments(), request)
                strategy.setCacheHeaders()
                return result

        return mapply(ob, request.getPositionalArguments(), request)
开发者ID:Zojax,项目名称:zojax.cacheheaders,代码行数:20,代码来源:publication.py


示例19: callObject

 def callObject(self, request, ob):
     orig = ob
     if not IHTTPException.providedBy(ob):
         ob = component.queryMultiAdapter((ob, request),
                                         name=request.method)
         checker = selectChecker(ob)
         if checker is not None:
             checker.check(ob, '__call__')
         ob = getattr(ob, request.method, None)
         if ob is None:
             raise GrokMethodNotAllowed(orig, request)
     return mapply(ob, request.getPositionalArguments(), request)
开发者ID:jean,项目名称:grokcore.rest,代码行数:12,代码来源:publication.py


示例20: testClass

    def testClass(self):
        values = {'a':2, 'b':3, 'c':5}
        class c(object):
            a = 3
            def __call__(self, b, c=4):
                return '%d%d%d' % (self.a, b, c)
            compute = __call__
        cc = c()
        v = mapply(cc, (), values)
        self.failUnlessEqual(v, '335')

        del values['c']
        v = mapply(cc.compute, (), values)
        self.failUnlessEqual(v, '334')

        class c2:
            """Must be a classic class."""
            
        c2inst = c2()
        c2inst.__call__ = cc
        v = mapply(c2inst, (), values)
        self.failUnlessEqual(v, '334')
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:22,代码来源:test_mapply.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python publish.publish函数代码示例发布时间:2022-05-26
下一篇:
Python browser.IBrowserRequest类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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