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 details)
Built Distribution
File details
Details for the file simpel-hookup-0.1.tar.gz
.
File metadata
- Download URL: simpel-hookup-0.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18d35d38d2e35e0173f1782c4f38ea2665c998ef89945bde84b428c2c6b86574 |
|
MD5 | 08435bf34efb61c1731ed65d8e5ec74b |
|
BLAKE2b-256 | a5e0f200e48171ad20747531e7ce8da2f791046dde616cc1f8f9d0f462dc81cc |
File details
Details for the file simpel_hookup-0.1-py3-none-any.whl
.
File metadata
- Download URL: simpel_hookup-0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.27.1 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da50abd9a2e3fcae92aa2ac113bacf36d1a3a620c06e50f7fe6f5db783184bde |
|
MD5 | 5ef1ad30e3c0e0c3fa882d9669dbca06 |
|
BLAKE2b-256 | d3d3497988953bd10d66705144ea5849ef2c5bbb50b97a96a21ebb97fae102cd |