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

Python validate_jsonp.is_valid_jsonp_callback_value函数代码示例

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

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



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

示例1: render

    def render(self, request):
        cb = request.GET.get('callback', None)
        seria = simplejson.dumps(self.construct(), cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4)

        # Callback
        if cb and is_valid_jsonp_callback_value(cb):
            return '%s(%s)' % (cb, seria)

        return seria
开发者ID:fern4lvarez,项目名称:django-piston,代码行数:9,代码来源:emitters.py


示例2: write

    def write(self, outfile, encoding):
        request = self.feed['request']

        # Check for a callback param, validate it before use
        callback = request.GET.get('callback', None)
        if callback is not None:
            if not validate_jsonp.is_valid_jsonp_callback_value(callback):
                callback = None

        items_out = []
        for item in self.items:
            document = item['obj']

            # Include some of the simple elements from the preprocessed item
            item_out = dict((x, item[x]) for x in (
                'link', 'title', 'pubdate', 'author_name', 'author_link',
            ))

            # HACK: DocumentFeed is the superclass of RevisionFeed. In this
            # case, current_revision is the revision itself.
            # TODO: Refactor this out into separate DocumentFeed and
            # RevisionFeed subclasses of Feed.
            if hasattr(document, 'current_revision'):
                revision = document.current_revision
            else:
                revision = document

            profile = UserProfile.objects.get(user=revision.creator)
            if hasattr(profile, 'gravatar'):
                item_out['author_avatar'] = profile.gravatar

            summary = revision.summary
            if summary:
                item_out['summary'] = summary

            # Linkify the tags used in the feed item
            categories = dict(
                (x, request.build_absolute_uri(
                        reverse('wiki.views.list_documents',
                                kwargs={'tag': x})))
                for x in item['categories']
            )
            if categories:
                item_out['categories'] = categories

            #TODO: What else might be useful in a JSON feed of documents?

            items_out.append(item_out)

        data = items_out

        if callback:
            outfile.write('%s(' % callback)
        outfile.write(json.dumps(data, default=self._encode_complex))
        if callback:
            outfile.write(')')
开发者ID:rajeshvv,项目名称:kuma,代码行数:56,代码来源:feeds.py


示例3: write

    def write(self, outfile, encoding):
        # Check for a callback param, validate it before use
        callback = self.feed['request'].GET.get('callback', None)
        if callback is not None:
            if not validate_jsonp.is_valid_jsonp_callback_value(callback):
                callback = None

        items_out = []
        for item in self.items:
            
            avatar_href = avatar_url(item['obj'].claimed_by, 64)
            if avatar_href.startswith('/'):
                avatar_href = self.request.build_absolute_uri(avatar_href)

            a_object = item['activity']['object']

            item_out = {
                'postedTime': item['pubdate'],
                'verb': item['activity']['verb'],
                'actor': {
                    'objectType': 'http://activitystrea.ms/schema/1.0/person',
                    'id': get_tag_uri(item['author_link'], item['pubdate']),
                    'displayName': item['author_name'],
                    'permalinkUrl': item['author_link'],
                    'image': {
                        'url': avatar_href, 
                        'width':'64', 
                        'height':'64',
                    }
                },
                'object': {
                    'objectType': a_object['object-type'],
                    'id': get_tag_uri(a_object['link'], item['pubdate']),
                    'displayName': a_object['name'],
                    'permalinkUrl': a_object['link'],
                    'image': {
                        'url': a_object['preview']['href'],
                        'width': a_object['preview']['width'],
                        'height': a_object['preview']['height'],
                    }
                },
            }
            items_out.append(item_out)

        data = {
            "items": items_out
        }

        if callback: outfile.write('%s(' % callback)
        outfile.write(json.dumps(data, default=self._encode_complex))
        if callback: outfile.write(')')
开发者ID:lmorchard,项目名称:badger,代码行数:51,代码来源:feeds.py


示例4: write

    def write(self, outfile, encoding):
        request = self.feed['request']

        # Check for a callback param, validate it before use
        callback = request.GET.get('callback', None)
        if callback is not None:
            if not validate_jsonp.is_valid_jsonp_callback_value(callback):
                callback = None

        items_out = []
        for item in self.items:

            # Include some of the simple elements from the preprocessed feed item
            item_out = dict( (x, item[x]) for x in (
                'link', 'title', 'pubdate', 'author_name', 'author_link',
            ))

            item_out['author_avatar'] = item['obj'].creator.get_profile().gravatar

            # Linkify the tags used in the feed item
            item_out['categories'] = dict(
                (x, request.build_absolute_uri(reverse('demos_tag', kwargs={'tag':x})))
                for x in item['categories']
            )

            # Include a few more, raw from the submission object itself.
            item_out.update( (x, unicode(getattr(item['obj'], x))) for x in (
                'summary', 'description',
            ))

            item_out['featured'] = item['obj'].featured

            # Include screenshot as an absolute URL.
            item_out['screenshot'] = request.build_absolute_uri(
                item['obj'].screenshot_url(1))

            # HACK: This .replace() should probably be done in the model
            item_out['thumbnail'] = request.build_absolute_uri(
                item['obj'].thumbnail_url(1))

            #TODO: What else might be useful in a JSON feed of demo submissions?
            # Comment, like, view counts may change too much for caching to be useful

            items_out.append(item_out)

        data = items_out

        if callback: outfile.write('%s(' % callback)
        outfile.write(json.dumps(data, default=self._encode_complex))
        if callback: outfile.write(')')
开发者ID:g1angel,项目名称:kuma,代码行数:50,代码来源:feeds.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python validation.cast_integer函数代码示例发布时间:2022-05-26
下一篇:
Python validate_email.validate_email函数代码示例发布时间: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