當前位置: 首頁>>代碼示例>>Python>>正文


Python StudyPerson.from_name_and_affiliation方法代碼示例

本文整理匯總了Python中qiita_db.study.StudyPerson.from_name_and_affiliation方法的典型用法代碼示例。如果您正苦於以下問題:Python StudyPerson.from_name_and_affiliation方法的具體用法?Python StudyPerson.from_name_and_affiliation怎麽用?Python StudyPerson.from_name_and_affiliation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qiita_db.study.StudyPerson的用法示例。


在下文中一共展示了StudyPerson.from_name_and_affiliation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_post_new_person

# 需要導入模塊: from qiita_db.study import StudyPerson [as 別名]
# 或者: from qiita_db.study.StudyPerson import from_name_and_affiliation [as 別名]
    def test_post_new_person(self):
        body = {'name': 'Boaty McBoatFace', 'affiliation': 'UCSD',
                'email': '[email protected]', 'phone': '720-876-5309'}

        response = self.post('/api/v1/person', data=body, headers=self.headers)
        self.assertEqual(response.code, 201)
        obs = json_decode(response.body)
        exp = StudyPerson.from_name_and_affiliation(body['name'],
                                                    body['affiliation']).id
        self.assertEqual(exp, obs['id'])
開發者ID:antgonza,項目名稱:qiita,代碼行數:12,代碼來源:test_study_person.py

示例2: get

# 需要導入模塊: from qiita_db.study import StudyPerson [as 別名]
# 或者: from qiita_db.study.StudyPerson import from_name_and_affiliation [as 別名]
    def get(self, *args, **kwargs):
        name = self.get_argument('name', None)
        affiliation = self.get_argument('affiliation', None)

        if name is None and affiliation is None:
            # Retrieve the list of all the StudyPerson
            sp = [{'name': p.name, 'affiliation': p.affiliation}
                  for p in StudyPerson.iter()]
            self.write(json_encode(sp))
            self.finish()
        elif name is not None and affiliation is not None:
            try:
                p = StudyPerson.from_name_and_affiliation(name, affiliation)
            except QiitaDBLookupError:
                self.fail('Person not found', 404)
                return
            self.write({'address': p.address, 'phone': p.phone,
                        'email': p.email, 'id': p.id})
            self.finish()
        else:
            arg_name = 'name' if name is None else 'affiliation'
            raise MissingArgumentError(arg_name)
開發者ID:ElDeveloper,項目名稱:qiita,代碼行數:24,代碼來源:study_person.py


注:本文中的qiita_db.study.StudyPerson.from_name_and_affiliation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。