def fill_init_data(): from tests.scientist_data import Scientist from scientist.scientist_bl import ScientistBL from tests.project_data import Project from project.project_bl import ProjectBL scientist_data = Scientist.get_scientist() print 'Creating init scientists' try: for k, val in scientist_data.iteritems(): yield ScientistBL.create(scientist_dict=val, test_mode=True) except Exception, ex: logging.exception(ex) raise
def post(self, *args, **kwargs): print u'scientist post' scientist_dict = json.loads(self.get_argument(u'data', u'{}')) print scientist_dict scientist_photo = dict( raw_image=self.request.files.get('raw_image', []), raw_image_coords=scientist_dict.pop(u'raw_image_coords', {}) ) try: response = yield ScientistBL.create(scientist_dict=scientist_dict, scientist_photo=scientist_photo) self.set_secure_cookie(u'scientist', str(response[u'scientist_id'])) except Exception, ex: logging.info('Exc on create scientist:') logging.exception(ex) response = dict( message=ex.message )