341 with self.internal_session() as session: |
341 with self.internal_session() as session: |
342 try: |
342 try: |
343 deserialize_schema(appschema, session) |
343 deserialize_schema(appschema, session) |
344 except BadSchemaDefinition: |
344 except BadSchemaDefinition: |
345 raise |
345 raise |
346 except Exception, ex: |
346 except Exception as ex: |
347 import traceback |
347 import traceback |
348 traceback.print_exc() |
348 traceback.print_exc() |
349 raise Exception('Is the database initialised ? (cause: %s)' % |
349 raise Exception('Is the database initialised ? (cause: %s)' % |
350 (ex.args and ex.args[0].strip() or 'unknown')), \ |
350 (ex.args and ex.args[0].strip() or 'unknown')), \ |
351 None, sys.exc_info()[-1] |
351 None, sys.exc_info()[-1] |
783 # Zeroed to avoid useless overhead with pyro |
783 # Zeroed to avoid useless overhead with pyro |
784 rset._rqlst = None |
784 rset._rqlst = None |
785 return rset |
785 return rset |
786 except (Unauthorized, RQLSyntaxError): |
786 except (Unauthorized, RQLSyntaxError): |
787 raise |
787 raise |
788 except ValidationError, ex: |
788 except ValidationError as ex: |
789 # need ValidationError normalization here so error may pass |
789 # need ValidationError normalization here so error may pass |
790 # through pyro |
790 # through pyro |
791 if hasattr(ex.entity, 'eid'): |
791 if hasattr(ex.entity, 'eid'): |
792 ex.entity = ex.entity.eid # error raised by yams |
792 ex.entity = ex.entity.eid # error raised by yams |
793 args = list(ex.args) |
793 args = list(ex.args) |
1355 edited.set_defaults() |
1355 edited.set_defaults() |
1356 if session.is_hook_category_activated('integrity'): |
1356 if session.is_hook_category_activated('integrity'): |
1357 edited.check(creation=True) |
1357 edited.check(creation=True) |
1358 try: |
1358 try: |
1359 source.add_entity(session, entity) |
1359 source.add_entity(session, entity) |
1360 except UniqueTogetherError, exc: |
1360 except UniqueTogetherError as exc: |
1361 userhdlr = session.vreg['adapters'].select( |
1361 userhdlr = session.vreg['adapters'].select( |
1362 'IUserFriendlyError', session, entity=entity, exc=exc) |
1362 'IUserFriendlyError', session, entity=entity, exc=exc) |
1363 userhdlr.raise_user_exception() |
1363 userhdlr.raise_user_exception() |
1364 self.add_info(session, entity, source, extid, complete=False) |
1364 self.add_info(session, entity, source, extid, complete=False) |
1365 edited.saved = entity._cw_is_saved = True |
1365 edited.saved = entity._cw_is_saved = True |
1421 if session.is_hook_category_activated('integrity'): |
1421 if session.is_hook_category_activated('integrity'): |
1422 edited.check() |
1422 edited.check() |
1423 try: |
1423 try: |
1424 source.update_entity(session, entity) |
1424 source.update_entity(session, entity) |
1425 edited.saved = True |
1425 edited.saved = True |
1426 except UniqueTogetherError, exc: |
1426 except UniqueTogetherError as exc: |
1427 etype, rtypes = exc.args |
1427 etype, rtypes = exc.args |
1428 problems = {} |
1428 problems = {} |
1429 for col in rtypes: |
1429 for col in rtypes: |
1430 problems[col] = session._('violates unique_together constraints (%s)') % (','.join(rtypes)) |
1430 problems[col] = session._('violates unique_together constraints (%s)') % (','.join(rtypes)) |
1431 raise ValidationError(entity.eid, problems) |
1431 raise ValidationError(entity.eid, problems) |