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()}
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})