Skip to main content

Simpel global hook registry for django

Project description

🚀 Simpel Hookup

Simpel function hook for Django. Install :

pip install simpel-hookup

Simpel hookup secara otomatis akan mencari hooks.py di dalam setiap aplikasi Django yang terinstall dalam project.

Registrasi hooks

# app/hooks.py

import simpel_hookup as hookup

@hookup.register("PROCESS_TEXT_HOOKS", order=1)
def process_text_replace_space(text):
    text = text.replace(" ", "-")
    print(text)
    return text

@hookup.register("PROCESS_TEXT_HOOKS", order=2)
def process_text_replace_dash(text):
    text = text.replace("-", "_")
    print(text)
    return text

Memanggil hook

# app/views.py
from django.http.response import HttpResponse
import simpel_hookup as hookup

def index(request):
    text = "Lorem ipsum dolor sit amet"

    hook_funcs = hookup.get_hooks('PROCESS_TEXT_HOOKS')
    for func in hook_funcs:
        text = func(text)

    return HttpResponse(text)

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpel-hookup-0.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

simpel_hookup-0.1-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page