Skip to main content

version license pyversions pipeline status coverage

flask-objectid-converter

Provides url converters for flask to support pymonogs ObjectIDs

I found the snippet from here by Armin Ronacher but could not find a package for it.

Usage

  • add the Converter to the flask app
  • use it in routes

Add Converter to app:

The package defines two converters to use:

  • ObjectIDConverter: stringify the id
  • Base64ObjectIDConverter: produces smaller strings by encoding to base64
from flask import Flask
from flask_objectid_converter import ObjectIDConverter

app = Flask(__name__)
app.url_map.converters['objectid'] = ObjectIDConverter

Use in routes

@app.route('/users/<objectid:oid>')
def get_user(oid):
    return User.objects.get(id=oid)

Throws 404 if the requested value cant be decoded

get route via url_for

from flask import url_for
url_for(get_user, oid=User.id)

Testing

python setup.py test

Possible extensions

Make the package a proper flask extension with init_app, encode, decode functions, configuration of conversion algorithm (specify alphabet)...

Changelog

  • 1.0.0: Inital version. Encodes to base64 by default.
  • 2.0.0: Provide two converter classes. A simple one and a base64 encoding one. Drop python2 support.

Metadata

Release files for flask-objectid-converter 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-objectid-converter 2.0.0
File Size Uploaded Provenance Actions
flask-objectid-converter-2.0.0.tar.gz 3.1 kB Without provenance Details for flask-objectid-converter-2.0.0.tar.gz

Release files / flask-objectid-converter-2.0.0.tar.gz

Download URL flask-objectid-converter-2.0.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
544934f41aeb3345da5de4082b8151110ad793b5915898a5a19e3f8527127d46
BLAKE2b-256 checksum
How to use checksums
9d028912ae72712108a75d141645a5a8b4b59eaa34ad3bdac6d784039b9f61aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

Security for flask-objectid-converter 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page