How to use the sqlakeyset.results.s.custom_unserializations function in sqlakeyset

To help you get started, we’ve selected a few sqlakeyset examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / vulncode-db / app / review / routes.py View on Github external
from lib.utils import parse_pagination_param

bp = Blueprint("review", __name__, url_prefix="/review")
db = DEFAULT_DATABASE


def serialize_enum(val):
    return 's', val.name


def unserialize_enum(val):
    return val


sqlakeysetserial.custom_serializations = {VulnerabilityState: serialize_enum}
sqlakeysetserial.custom_unserializations = {
    VulnerabilityState: unserialize_enum
}


# Create a catch all route for profile identifiers.
@bp.route("/list")
@admin_required()
def list(vendor: str = None, profile: str = None):
    entries = db.session.query(Vulnerability, Nvd)
    entries = entries.filter(
        Vulnerability.state != VulnerabilityState.PUBLISHED)
    entries = entries.outerjoin(Vulnerability,
                                Nvd.cve_id == Vulnerability.cve_id)
    entries = entries.order_by(asc(Vulnerability.state), desc(Nvd.id))

    bookmarked_page = parse_pagination_param("review_p")