コード例 #1
0
 def get(self):
     contact_id = self.request.matchdict.get('contact_id')
     try:
         contact = CoreContact.get(self.user, contact_id)
     except NotFound:
         raise ResourceNotFound('No such contact')
     return {'contacts': ReturnContact.build(contact).serialize()}
コード例 #2
0
ファイル: contact.py プロジェクト: ziir/caliopen.api.user
 def get(self):
     contact_id = self.request.matchdict.get('contact_id')
     try:
         contact = CoreContact.get(self.user, contact_id)
     except NotFound:
         raise ResourceNotFound('No such contact')
     return {'contacts': ReturnContact.build(contact).serialize()}
コード例 #3
0
 def collection_post(self):
     """Create a new contact from json post data structure."""
     data = self.request.json
     contact_param = NewContact(data)
     try:
         contact_param.validate()
     except Exception as exc:
         raise ValidationError(exc)
     contact = CoreContact.create(self.user, contact_param)
     out_contact = ReturnContact.build(contact).serialize()
     return Response(status=201, body={'contacts': out_contact})
コード例 #4
0
ファイル: contact.py プロジェクト: ziir/caliopen.api.user
 def collection_post(self):
     """Create a new contact from json post data structure."""
     data = self.request.json
     contact_param = NewContact(data)
     try:
         contact_param.validate()
     except Exception as exc:
         raise ValidationError(exc)
     contact = CoreContact.create(self.user, contact_param)
     out_contact = ReturnContact.build(contact).serialize()
     return Response(status=201, body={'contacts': out_contact})