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
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)
Built Distribution
Close
Hashes for simpel_hookup-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da50abd9a2e3fcae92aa2ac113bacf36d1a3a620c06e50f7fe6f5db783184bde |
|
MD5 | 5ef1ad30e3c0e0c3fa882d9669dbca06 |
|
BLAKE2b-256 | d3d3497988953bd10d66705144ea5849ef2c5bbb50b97a96a21ebb97fae102cd |