当前位置: 首页>>代码示例>>Python>>正文


Python model_to_dict.ModelToDict类代码示例

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


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

示例1: _render

    def _render(self, event_key):
        self._set_event(event_key)

        matches = self.event.matches
        match_dicts = [ModelToDict.matchConverter(match) for match in matches]

        return json.dumps(match_dicts, ensure_ascii=True)
开发者ID:cmlicata,项目名称:the-blue-alliance,代码行数:7,代码来源:api_event_controller.py

示例2: _build_dict

 def _build_dict(self):
     data = {}
     data['message_type'] = NotificationType.type_names[self._type]
     data['message_data'] = {}
     data['message_data']['event_name'] = self.event.name
     data['message_data']['match'] = ModelToDict.matchConverter(self.match)
     return data
开发者ID:cmlicata,项目名称:the-blue-alliance,代码行数:7,代码来源:match_score.py

示例3: _render

    def _render(self, team_key):
        self._set_team(team_key)

        awards = TeamAwardsQuery(self.team_key).fetch()

        awards_list = [ModelToDict.awardConverter(award) for award in awards]
        return json.dumps(awards_list, ensure_ascii=True)
开发者ID:DNGros,项目名称:the-blue-alliance,代码行数:7,代码来源:api_team_controller.py

示例4: _render

    def _render(self, event_key):
        self._set_cache_header_length(60 * 60)
        self._set_event(event_key)

        event_dict = ModelToDict.eventConverter(self.event)

        return json.dumps(event_dict, ensure_ascii=True)
开发者ID:sapchan,项目名称:the-blue-alliance,代码行数:7,代码来源:api_event_controller.py

示例5: _render

    def _render(self, team_key, year=None):
        self._set_team(team_key)

        media_keys = Media.query(Media.references == self.team.key, Media.year == self.year).fetch(500, keys_only=True)
        medias = ndb.get_multi(media_keys)
        media_list = [ModelToDict.mediaConverter(media) for media in medias]
        return json.dumps(media_list, ensure_ascii=True)
开发者ID:Captain-Dude,项目名称:the-blue-alliance,代码行数:7,代码来源:api_team_controller.py

示例6: _build_dict

 def _build_dict(self):
     data = {}
     data['message_type'] = NotificationType.type_names[self._type]
     data['message_data'] = {}
     data['message_data']['event_name'] = self.event.name
     data['message_data']['event_key'] = self.event.key_name
     data['message_data']['awards'] = [ModelToDict.awardConverter(award) for award in AwardHelper.organizeAwards(self.event.awards)]
     return data
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:8,代码来源:awards_updated.py

示例7: _render

    def _render(self, district_abbrev, year=None):
        self._set_district(district_abbrev)

        events = DistrictEventsQuery("{}{}".format(self.year, self.district_abbrev)).fetch()

        events = [ModelToDict.eventConverter(event) for event in events]

        return json.dumps(events, ensure_ascii=True)
开发者ID:samuelcouch,项目名称:the-blue-alliance,代码行数:8,代码来源:api_district_controller.py

示例8: _build_dict

 def _build_dict(self):
     data = {}
     data['notification_type'] = NotificationType.type_names[self._type]
     data['message_data'] = {}
     data['message_data']['event_name'] = self.event.name
     data['message_data']['event_key'] = self.event.key_name
     data['message_data']['event'] = ModelToDict.eventConverter(self.event)
     return data
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:8,代码来源:alliance_selections.py

示例9: _render

    def _render(self, district_abbrev, year=None):
        self._set_district(district_abbrev)

        event_keys = Event.query(Event.year == self.year, Event.event_district_enum == self.district).fetch(None, keys_only=True)
        events = ndb.get_multi(event_keys)

        events = [ModelToDict.eventConverter(event) for event in events]

        return json.dumps(events, ensure_ascii=True)
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:9,代码来源:api_district_controller.py

示例10: get

    def get(self, model_type):
        if not self.user_bundle.user:
            self.response.set_status(401)
            return

        favorites = Favorite.query(
            Favorite.model_type==int(model_type),
            ancestor=ndb.Key(Account, self.user_bundle.user.user_id())).fetch()
        self.response.out.write(json.dumps([ModelToDict.favoriteConverter(fav) for fav in favorites]))
开发者ID:hamster1147,项目名称:the-blue-alliance,代码行数:9,代码来源:ajax_controller.py

示例11: _render

    def _render(self, team_key, year=None):
        self._write_cache_headers(61)

        self.team = Team.get_by_id(self.team_key)
        if self.team is None:
            self._errors = json.dumps({"404": "%s team not found" % self.team_key})
            self.abort(404)

        events_sorted, matches_by_event_key, awards_by_event_key, _ = TeamDetailsDataFetcher.fetch(self.team, self.year)
        team_dict = ModelToDict.teamConverter(self.team)

        team_dict["events"] = list()
        for event in events_sorted:
            event_dict = ModelToDict.eventConverter(event)
            event_dict["matches"] = [ModelToDict.matchConverter(match) for match in matches_by_event_key.get(event.key, [])]
            event_dict["awards"] = [ModelToDict.awardConverter(award) for award in awards_by_event_key.get(event.key, [])]
            team_dict["events"].append(event_dict)

        return json.dumps(team_dict, ensure_ascii=True)
开发者ID:linuxuser0,项目名称:the-blue-alliance,代码行数:19,代码来源:api_team_controller.py

示例12: test_build

    def test_build(self):
        expected = {}
        expected['message_type'] = NotificationType.type_names[NotificationType.MATCH_SCORE]
        expected['message_data'] = {}
        expected['message_data']['event_name'] = self.event.name
        expected['message_data']['match'] = ModelToDict.matchConverter(self.match)

        data = self.notification._build_dict()

        self.assertEqual(expected, data)
开发者ID:BowlesCR,项目名称:the-blue-alliance,代码行数:10,代码来源:test_notification_score.py

示例13: _render_android

    def _render_android(self):
        gcm_keys = self.keys[ClientType.OS_ANDROID]

        data = {}
        data["message_type"] = NotificationType.type_names[NotificationType.MATCH_SCORE]
        data["message_data"] = {}
        data["message_data"]["event_name"] = self.match.event.get().name
        data["message_data"]["match"] = ModelToDict.matchConverter(self.match)

        return GCMMessage(gcm_keys, data)
开发者ID:dewdn2,项目名称:the-blue-alliance,代码行数:10,代码来源:match_score.py

示例14: _render

    def _render(self, year=None):
        if self.year < 1992 or self.year > datetime.now().year + 1:
            self._errors = json.dumps({"404": "No events found for %s" % self.year})
            self.abort(404)

        keys = Event.query(Event.year == self.year).fetch(1000, keys_only=True)
        events = ndb.get_multi(keys)

        event_list = [ModelToDict.eventConverter(event) for event in events]

        return json.dumps(event_list, ensure_ascii=True)
开发者ID:Captain-Dude,项目名称:the-blue-alliance,代码行数:11,代码来源:api_event_controller.py

示例15: test_build

    def test_build(self):
        expected = {}
        expected['notification_type'] = NotificationType.type_names[NotificationType.AWARDS]
        expected['message_data'] = {}
        expected['message_data']['event_name'] = self.event.name
        expected['message_data']['event_key'] = self.event.key_name
        expected['message_data']['awards'] = [ModelToDict.awardConverter(award) for award in AwardHelper.organizeAwards(self.event.awards)]

        data = self.notification._build_dict()

        self.assertEqual(expected, data)
开发者ID:ZachOrr,项目名称:the-blue-alliance,代码行数:11,代码来源:test_notification_awards.py


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