using multi template on one view_config
Project description
this is dirty implementation.
## how to use
- define selectable renderer.
- using selectable renderer as renderer factory
- using selectable renderer with view_config settings
### sample
## define selectable renderer
from pyramid_selectable_renderer import SelectableRendererSetup
from pyramid_selectable_renderer.custom import ReceiveTemplatePathCandidatesDict
from pyramid_selectable_renderer.custom import SelectByRetvalLeftGen
ValidateTrueOrNot = SelectableRendererSetup(
ReceiveTemplatePathCandidatesDict,
SelectByRetvalLeftGen.generate(lambda x : x),
renderer_name = "validate_true_or_not")
## in __init__.py
def includeme(config):
ValidateTrueOrNot.register_to(config) # enable to use selectable renderer
## in view.py
@view_config(route_name="sample.confirm",
renderer=ValidateTrueOrNot({True: "foo:success.pt", False: "foo:failure.pt"}))
def form_confirm_view(context, request):
form = ValidateForm(request.POST):
return form.validate(), {"form": form}
## how to use
- define selectable renderer.
- using selectable renderer as renderer factory
- using selectable renderer with view_config settings
### sample
## define selectable renderer
from pyramid_selectable_renderer import SelectableRendererSetup
from pyramid_selectable_renderer.custom import ReceiveTemplatePathCandidatesDict
from pyramid_selectable_renderer.custom import SelectByRetvalLeftGen
ValidateTrueOrNot = SelectableRendererSetup(
ReceiveTemplatePathCandidatesDict,
SelectByRetvalLeftGen.generate(lambda x : x),
renderer_name = "validate_true_or_not")
## in __init__.py
def includeme(config):
ValidateTrueOrNot.register_to(config) # enable to use selectable renderer
## in view.py
@view_config(route_name="sample.confirm",
renderer=ValidateTrueOrNot({True: "foo:success.pt", False: "foo:failure.pt"}))
def form_confirm_view(context, request):
form = ValidateForm(request.POST):
return form.validate(), {"form": form}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyramid_selectable_renderer-0.0.4.tar.gz
.
File metadata
- Download URL: pyramid_selectable_renderer-0.0.4.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f18a5e163adb725fdc54659a547cd58a23c15ab79305573b011c20d15af7e76 |
|
MD5 | 42c063a39b873af63959cf341578d31b |
|
BLAKE2b-256 | 424996a5e4cebed89bb40b9a1dbdd8ffc30e4e894e9ca21966646cb4df0fba52 |