Skip to content
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

Closed
wants to merge 10 commits into from
Closed

Enhancement: Route-Prefixing re Issue #406 #414

wants to merge 10 commits into from

Conversation

simonyarde
Copy link

#406

route_prefix doesn't allow the prefix pattern to match without a
trailing slash

Suggested solution:

  • Create a route_pattern class (extending list) to centralise route joining operations, principally providing a __str__ method.
  • Implement @mmerickel's route_prefix configurative behaviour via route_pattern.match_slash_style bool attribute, where left-most item influences the route-pattern slash-style (slash-appended or non-slash-appended).
  • Provide (optional) route_suffix as the logical compliment to route_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-most include's route-suffix added last.

#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
@simonyarde
Copy link
Author

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 route_prefix to route_prefix_list as appropriate (same for route_suffix).

…refix_list varname to route_prefix, same for route_suffix, prepend suffixes to avoid later copy-and-reverse
…-pattern

operations in ``route_pattern class``, and  make code that uses
``route_pattern`` class neater. Reformat text-width of doc additions.
@simonyarde
Copy link
Author

Finally bring all thinking into a neat route_pattern object and route_pattern.match_slash_style attribute, in order to centralise operations with route-patterns.

@simonyarde
Copy link
Author

Closed as I have proposed an alternative solution and code

@simonyarde simonyarde closed this Feb 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant