32. ADVANCED CONFIGURATION
32.1.2 Automatic Conflict Resolution
If your code uses the include() method to include external configuration, some conflicts are automatically resolved. Configuration statements that are made as the result of an “include” will be overridden by configuration statements that happen within the caller of the “include” method.
Automatic conflict resolution supports this goal: if a user wants to reuse a Pyramid application, and they want to customize the configuration of this application without hacking its code “from outside”, they can “include” a configuration function from the package and override only some of its configuration statements within the code that does the include. No conflicts will be generated by configuration statements within the code which does the including, even if configuration statements in the included code would conflict if it was moved “up” to the calling code.
32.1.3 Methods Which Provide Conflict Detection
These are the methods of the configurator which provide conflict detection:
add_view(), add_route(), add_renderer(), set_request_factory(), set_session_factory(), set_request_property(), set_root_factory(), set_view_mapper(), set_authentication_policy(), set_authorization_policy(), set_renderer_globals_factory(), set_locale_negotiator(), set_default_permission(), add_traverser(), add_resource_url_adapter(), and add_response_adapter().
add_static_view() also indirectly provides conflict detection, because it’s implemented in terms of the conflict-aware add_route and add_view methods.
32.2 Including Configuration from External Sources
Some application programmers will factor their configuration code in such a way that it is easy to reuse and override configuration statements. For example, such a developer might factor out a function used to add routes to his application:
1 def add_routes(config):
2config.add_route(...)
Rather than calling this function directly with config as an argument. Instead, use pyramid.config.Configuration.include():