Ejemplo n.º 1
0
def validate_flow_page(vctx, location, page_desc):
    # type: (ValidationContext, Text, Any) -> None
    if not hasattr(page_desc, "id"):
        raise ValidationError(
                string_concat(
                    "%s: ",
                    ugettext("flow page has no ID"))
                % location)

    validate_identifier(vctx, location, page_desc.id)

    from course.content import get_flow_page_class
    try:
        class_ = get_flow_page_class(vctx.repo, page_desc.type, vctx.commit_sha)
        class_(vctx, location, page_desc)
    except ValidationError:
        raise
    except:
        tp, e, __ = sys.exc_info()

        from traceback import format_exc
        raise ValidationError(
                string_concat(
                    "%(location)s: ",
                    _("could not instantiate flow page"),
                    ": %(err_type)s: "
                    "%(err_str)s<br><pre>%(format_exc)s</pre>")
                % {
                    'location': location,
                    "err_type": tp.__name__,  # type: ignore
                    "err_str": str(e),
                    'format_exc': format_exc()})
Ejemplo n.º 2
0
def validate_flow_page(vctx, location, page_desc):
    if not hasattr(page_desc, "id"):
        raise ValidationError(
                string_concat(
                    "%s: ",
                    ugettext("flow page has no ID"))
                % location)

    validate_identifier(vctx, location, page_desc.id)

    from course.content import get_flow_page_class
    try:
        class_ = get_flow_page_class(vctx.repo, page_desc.type, vctx.commit_sha)
        class_(vctx, location, page_desc)
    except ValidationError:
        raise
    except:
        tp, e, __ = sys.exc_info()

        from traceback import format_exc
        raise ValidationError(
                string_concat(
                    "%(location)s: ",
                    _("could not instantiate flow page"),
                    ": %(err_type)s: "
                    "%(err_str)s<br><pre>%(format_exc)s</pre>")
                % {
                    'location': location,
                    "err_type": tp.__name__,
                    "err_str": str(e),
                    'format_exc': format_exc()})
Ejemplo n.º 3
0
def validate_flow_page(ctx, location, page_desc):
    if not hasattr(page_desc, "id"):
        raise ValidationError("%s: flow page has no ID" % location)

    validate_identifier(location, page_desc.id)

    from course.content import get_flow_page_class
    try:
        class_ = get_flow_page_class(ctx.repo, page_desc.type, ctx.commit_sha)
        class_(ctx, location, page_desc)
    except ValidationError:
        raise
    except:
        tp, e, _ = sys.exc_info()

        from traceback import format_exc
        raise ValidationError(
                "%s: could not instantiate flow page: %s: %s<br><pre>%s</pre>"
                % (location, tp.__name__, str(e), format_exc()))
Ejemplo n.º 4
0
def validate_flow_page(ctx, location, page_desc):
    if not hasattr(page_desc, "id"):
        raise ValidationError("%s: flow page has no ID" % location)

    validate_identifier(location, page_desc.id)

    from course.content import get_flow_page_class
    try:
        class_ = get_flow_page_class(ctx.repo, page_desc.type, ctx.commit_sha)
        class_(ctx, location, page_desc)
    except ValidationError:
        raise
    except:
        tp, e, _ = sys.exc_info()

        from traceback import format_exc
        raise ValidationError(
            "%s: could not instantiate flow page: %s: %s<br><pre>%s</pre>" %
            (location, tp.__name__, str(e), format_exc()))