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

Python utils.log_api_action函数代码示例

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

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



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

示例1: get

    def get(self):
        if self.config.read_auth_key_required and not (self.auth and self.auth.read_permission):
            self.info(403, message="Missing or invalid authorization key", style="plain")
            return

        pfif_version = self.params.version

        # Note that self.request.get can handle multiple IDs at once; we
        # can consider adding support for multiple records later.
        record_id = self.request.get("id")
        if not record_id:
            self.info(400, message="Missing id parameter", style="plain")
            return

        person = model.Person.get(self.repo, record_id, filter_expired=False)
        if not person:
            self.info(400, message="No person record with ID %s" % record_id, style="plain")
            return
        notes = model.Note.get_by_person_record_id(self.repo, record_id)
        notes = [note for note in notes if not note.hidden]

        self.response.headers["Content-Type"] = "application/xml"
        records = [pfif_version.person_to_dict(person, person.is_expired)]
        note_records = map(pfif_version.note_to_dict, notes)
        utils.optionally_filter_sensitive_fields(records, self.auth)
        utils.optionally_filter_sensitive_fields(note_records, self.auth)
        pfif_version.write_file(self.response.out, records, lambda p: note_records)
        utils.log_api_action(self, ApiActionLog.READ, len(records), len(notes))
开发者ID:Gentlemanlylad5,项目名称:googlepersonfinder,代码行数:28,代码来源:api.py


示例2: get

    def get(self):
        if self.config.read_auth_key_required and not (
            self.auth and self.auth.read_permission):
            self.response.set_status(403)
            self.write('Missing or invalid authorization key\n')
            return

        pfif_version = self.params.version

        # Note that self.request.get can handle multiple IDs at once; we
        # can consider adding support for multiple records later.
        record_id = self.request.get('id')
        if not record_id:
            return self.error(400, 'Missing id parameter')

        person = model.Person.get(
            self.repo, record_id, filter_expired=False)
        if not person:
            return self.error(404, 'No person record with ID %s' % record_id)
        notes = model.Note.get_by_person_record_id(self.repo, record_id)
        notes = [note for note in notes if not note.hidden]

        self.response.headers['Content-Type'] = 'application/xml'
        records = [pfif_version.person_to_dict(person, person.is_expired)]
        note_records = map(pfif_version.note_to_dict, notes)
        utils.optionally_filter_sensitive_fields(records, self.auth)
        utils.optionally_filter_sensitive_fields(note_records, self.auth)
        pfif_version.write_file(
            self.response.out, records, lambda p: note_records)
        utils.log_api_action(
            self, ApiActionLog.READ, len(records), len(notes))
开发者ID:santoshsahoo,项目名称:personfinder,代码行数:31,代码来源:api.py


示例3: get

    def get(self):
        if self.config.search_auth_key_required and not (
            self.auth and self.auth.search_permission):
            self.info(
                403,
                message='Missing or invalid authorization key',
                style='plain')
            return

        pfif_version = self.params.version

        # Retrieve parameters and do some sanity checks on them.
        record_id = self.request.get('id')
        query_string = self.request.get('q')
        max_results = min(self.params.max_results or 100, HARD_MAX_RESULTS)

        results = []
        if record_id:
            # Search by record ID (always returns just 1 result or nothing).
            person = model.Person.get(self.repo, record_id)
            if person:
                results = [person]
        elif query_string:
            # Search by query words.
            if self.config.external_search_backends:
                query = TextQuery(query_string)
                results = external_search.search(self.repo, query, max_results,
                    self.config.external_search_backends)
            # External search backends are not always complete. Fall back to
            # the original search when they fail or return no results.
            if not results:
                if config.get('enable_fulltext_search'):
                    results = full_text_search.search(
                        self.repo, query_string, max_results)
                else:
                    results = indexing.search(
                        self.repo, TextQuery(query_string), max_results)
        else:
            self.info(
                400,
                message='Neither id nor q parameter specified',
                style='plain')

        records = [pfif_version.person_to_dict(result) for result in results]
        utils.optionally_filter_sensitive_fields(records, self.auth)

        # Define the function to retrieve notes for a person.
        def get_notes_for_person(person):
            notes = model.Note.get_by_person_record_id(
                self.repo, person['person_record_id'])
            notes = [note for note in notes if not note.hidden]
            records = map(pfif_version.note_to_dict, notes)
            utils.optionally_filter_sensitive_fields(records, self.auth)
            return records

        self.response.headers['Content-Type'] = 'application/xml; charset=utf-8'
        pfif_version.write_file(
            self.response.out, records, get_notes_for_person)
        utils.log_api_action(self, ApiActionLog.SEARCH, len(records))
开发者ID:aacn500,项目名称:personfinder,代码行数:59,代码来源:api.py


示例4: get

    def get(self):
        repos = model.Repo.list_launched()
        if self.repo:
            repos = [self.repo] if self.repo in repos else []

        self.response.headers['Content-Type'] = 'application/xml'
        atom.REPO_1_0.write_feed(
            self.response.out, repos, self.request.url, self.TITLE,
            get_latest_repo_updated_date(repos))
        utils.log_api_action(self, model.ApiActionLog.REPO)
开发者ID:Aloknayan,项目名称:personfinder,代码行数:10,代码来源:feeds.py


示例5: post

    def post(self):
        if not (self.auth and self.auth.subscribe_permission):
            return self.error(403, "Missing or invalid authorization key")

        subscription = model.Subscription.get(self.repo, self.params.id, self.params.subscribe_email)
        self.response.set_status(200)
        utils.log_api_action(self, ApiActionLog.UNSUBSCRIBE)
        if subscription:
            subscription.delete()
            return self.info(200, "Successfully unsubscribed")
        return self.info(200, "Not subscribed")
开发者ID:Gentlemanlylad5,项目名称:googlepersonfinder,代码行数:11,代码来源:api.py


示例6: post

    def post(self):
        if not (self.auth and self.auth.domain_write_permission):
            self.response.set_status(403)
            # TODO(ryok): i18n
            self.write('Missing or invalid authorization key.')
            return

        content = self.request.get('content')
        if not content:
            self.response.set_status(400)
            self.write('You need to specify at least one CSV file.')
            return

        # TODO(ryok): let the user select timezone.
        # TODO(ryok): accept more flexible date time format.
        # TODO(ryok): support non-UTF8 encodings.

        source_domain = self.auth.domain_write_permission
        records = importer.utf8_decoder(
                csv.DictReader(StringIO.StringIO(content)))
        try:
            records = [complete_record_ids(r, source_domain) for r in records]
        except csv.Error:
            self.response.set_status(400)
            self.write('The CSV file is formatted incorrectly.')
            return

        is_empty = lambda x: (x or '').strip()
        persons = [r for r in records if is_empty(r.get('full_name'))]
        notes = [r for r in records if is_empty(r.get('note_record_id'))]

        people_written, people_skipped, people_total = importer.import_records(
            self.repo, source_domain, importer.create_person, persons)
        notes_written, notes_skipped, notes_total = importer.import_records(
            self.repo, source_domain, importer.create_note, notes)

        utils.log_api_action(self, ApiActionLog.WRITE,
                             people_written, notes_written,
                             len(people_skipped), len(notes_skipped))

        self.render('import.html',
                    stats=[
                        Struct(type='Person',
                               written=people_written,
                               skipped=people_skipped,
                               total=people_total),
                        Struct(type='Note',
                               written=notes_written,
                               skipped=notes_skipped,
                               total=notes_total)],
                    **get_tag_params(self))
开发者ID:santoshsahoo,项目名称:personfinder,代码行数:51,代码来源:api.py


示例7: convert_time_fields

        source_domain = self.auth.domain_write_permission
        records = importer.utf8_decoder(generate_note_record_ids(
            convert_time_fields(csv.reader(lines))))
        try:
            records = [complete_record_ids(r, source_domain) for r in records]
        except csv.Error, e:
            self.error(400, message=
                'The CSV file is formatted incorrectly. (%s)' % e)
            return

        notes_written, notes_skipped, notes_total = importer.import_records(
            self.repo, source_domain, importer.create_note, records,
            believed_dead_permission=self.auth.believed_dead_permission,
            omit_duplicate_notes=True)

        utils.log_api_action(self, ApiActionLog.WRITE,
                             0, notes_written, 0, len(notes_skipped))

        self.render('import.html',
                    formats=get_requested_formats(self.env.path),
                    stats=[
                        Struct(type='Note',
                               written=notes_written,
                               skipped=notes_skipped,
                               total=notes_total)],
                    **get_tag_params(self))

    def import_persons(self, lines):
        # TODO(ryok): support non-UTF8 encodings.

        source_domain = self.auth.domain_write_permission
        records = importer.utf8_decoder(convert_time_fields(csv.reader(lines)))
开发者ID:aacn500,项目名称:personfinder,代码行数:32,代码来源:api.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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