MCPcopy
hub / github.com/Pylons/pyramid / include

Method include

src/pyramid/config/__init__.py:526–668  ·  view source on GitHub ↗

Include a configuration callable, to support imperative application extensibility. .. warning:: In versions of :app:`Pyramid` prior to 1.2, this function accepted ``*callables``, but this has been changed to support only a single callable. A configur

(self, callable, route_prefix=None)

Source from the content-addressed store, hash-verified

524 )
525
526 def include(self, callable, route_prefix=None):
527 """Include a configuration callable, to support imperative
528 application extensibility.
529
530 .. warning:: In versions of :app:`Pyramid` prior to 1.2, this
531 function accepted ``*callables``, but this has been changed
532 to support only a single callable.
533
534 A configuration callable should be a callable that accepts a single
535 argument named ``config``, which will be an instance of a
536 :term:`Configurator`. However, be warned that it will not be the same
537 configurator instance on which you call this method. The
538 code which runs as a result of calling the callable should invoke
539 methods on the configurator passed to it which add configuration
540 state. The return value of a callable will be ignored.
541
542 Values allowed to be presented via the ``callable`` argument to
543 this method: any callable Python object or any :term:`dotted Python
544 name` which resolves to a callable Python object. It may also be a
545 Python :term:`module`, in which case, the module will be searched for
546 a callable named ``includeme``, which will be treated as the
547 configuration callable.
548
549 For example, if the ``includeme`` function below lives in a module
550 named ``myapp.myconfig``:
551
552 .. code-block:: python
553 :linenos:
554
555 # myapp.myconfig module
556
557 def my_view(request):
558 from pyramid.response import Response
559 return Response('OK')
560
561 def includeme(config):
562 config.add_view(my_view)
563
564 You might cause it to be included within your Pyramid application like
565 so:
566
567 .. code-block:: python
568 :linenos:
569
570 from pyramid.config import Configurator
571
572 def main(global_config, **settings):
573 config = Configurator()
574 config.include('myapp.myconfig.includeme')
575
576 Because the function is named ``includeme``, the function name can
577 also be omitted from the dotted name reference:
578
579 .. code-block:: python
580 :linenos:
581
582 from pyramid.config import Configurator
583

Callers 15

setup_registryMethod · 0.95
setUpMethod · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 9

maybe_dottedMethod · 0.95
beginMethod · 0.95
endMethod · 0.95
ConfigurationErrorClass · 0.90
package_ofFunction · 0.90
getmoduleMethod · 0.80
getsourcefileMethod · 0.80
processSpecMethod · 0.80
route_prefix_contextMethod · 0.80

Tested by 1

setUpMethod · 0.76