-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Route-Prefixing re Issue #406 #414
Conversation
#406 route_prefix doesn't allow the prefix pattern to match without a trailing slash Enhances route-prefixing by offering greater configuration flexibility to resolve issue #406 comprehensively. Enabled by ``pyramid.allow_empty_pattern`` for BW compatibility. Relevant toward creating more-explicit configuration behavior and supporting project designs that use the non-slash-appended route-style without ugly workarounds. Supports TIMTOWTDI design defense. Option to ship Pyramid with whatever default is deemed most 'correct' as the web evolves. Affects project that: a.) enable ``pyramid.allow_empty_pattern``, AND; b.) mount an empty pattern under a prefix ('/prefix' + ''), AND; c.) expect a slash-appended route to be created ('/prefix/'). Docs: - Provided further route-prefixing design examples re sub-callables and nested prefixes where common usage might be to prefix a locale string to a module routes (e.g. ``/{_LOCALE_}/users/show``); - Documented enhanced route-prefix behaviour and added advisory note for existing projects that want to enable ``pyramid.allow_empty_pattern``.
…refix has configurative behaviour, and add complementary route-suffix behaviour to give control over the other end of the patterh i.e. control over creation of a slash-appended or non-slash-appended routes
Demonstrate approach of passing route_prefixes as lists instead of strings, in order to simplify code and do all route-pattern creation in add_route. Todo: change var names |
…refix_list varname to route_prefix, same for route_suffix, prepend suffixes to avoid later copy-and-reverse
…move list initialisation
…-pattern operations in ``route_pattern class``, and make code that uses ``route_pattern`` class neater. Reformat text-width of doc additions.
Finally bring all thinking into a neat |
Closed as I have proposed an alternative solution and code |
#406
Suggested solution:
route_pattern
class (extendinglist
) to centralise route joining operations, principally providing a__str__
method.route_prefix
configurative behaviour viaroute_pattern.match_slash_style
bool attribute, where left-most item influences the route-pattern slash-style (slash-appended or non-slash-appended).route_suffix
as the logical compliment toroute_prefix
, but having no configurative behaviour;route_prefix
affects the route-pattern after the addition of any suffixes. Route-suffixes are added outward with the outer-mostinclude
's route-suffix added last.