Skip to content

Instantly share code, notes, and snippets.

View alanjds's full-sized avatar

Alan Justino da Silva alanjds

  • Santo André, São Paulo/SP - Brazil
View GitHub Profile
@alanjds
alanjds / pure.py
Last active August 22, 2019 20:45
What CPython modules are Pure and what ones are C-based?
_original_import = __import__
def store_loader(name, module, storage):
try:
spec = module.__spec__
loader = spec.loader if type(spec.loader) == type else spec.loader.__class__
except Exception as err:
loader = type(err)
module = err
@alanjds
alanjds / decorators.py
Created August 3, 2020 18:59 — forked from garrypolley/decorators.py
Django decorate 3rd party app's views
# -*- coding: utf-8 -*-
from django.conf.urls import include
def decorated_include(urls, decorator)
"""Used to decorate all urls in a 3rd party app with a specific decorator"""
urls_to_decorate = include(urls)
for url_pattern in urls_to_decorate
url_pattern._callback = decorator(url_pattern._callback)