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 RecieveTemplatePathCandidatesDict
from pyramid_selectable_renderer.custom import SelectByRetvalLeftGen
ValidateTrueOrNot = SelectableRendererSetup(
RecieveTemplatePathCandidatesDict,
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 RecieveTemplatePathCandidatesDict
from pyramid_selectable_renderer.custom import SelectByRetvalLeftGen
ValidateTrueOrNot = SelectableRendererSetup(
RecieveTemplatePathCandidatesDict,
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.2.tar.gz
.
File metadata
- Download URL: pyramid_selectable_renderer-0.0.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09920229219f45a6908e755c8e924630811d3b224683cd230f01f37540298ffc |
|
MD5 | 4da2e7335f9047d8a34c4feb1582b520 |
|
BLAKE2b-256 | 9725dc82236966332ed620bde3dce7011003af2bceaf1ed67ccc98eabd54e4cb |