Skip to content

Instantly share code, notes, and snippets.

View ranvijay-sachan's full-sized avatar
🎯
Focusing

Ranvijay S ranvijay-sachan

🎯
Focusing
View GitHub Profile
@ranvijay-sachan
ranvijay-sachan / mixins.py
Created February 13, 2019 09:39 — forked from adamJLev/mixins.py
Atomic transactions and Django Rest Framework
from django.db import transaction
class AtomicMixin(object):
"""
Ensures we rollback db transactions on exceptions.
Idea from https://github.com/tomchristie/django-rest-framework/pull/1204
"""
@transaction.atomic()
def dispatch(self, *args, **kwargs):
return super(AtomicMixin, self).dispatch(*args, **kwargs)
@ranvijay-sachan
ranvijay-sachan / auth.py
Created July 22, 2017 10:03 — forked from koriaf/auth.py
django-oidc-provider and DRF example
"""
NOT PRODUCTION READY
Usage:
REST_FRAMEWORK = {
...
'DEFAULT_AUTHENTICATION_CLASSES': (
....
'ibr.users.accounts_api_v0.auth.OidcOauth2Auth'
@ranvijay-sachan
ranvijay-sachan / app.py
Last active June 17, 2017 05:23
parse unix passwd file
import os
from flask import Flask, request, render_template
from network.parse_passwd import get_remote_user_info
app = Flask(__name__)
@app.route('/login')