Hi,

A module's includeme function is called when the module is included
using config.include:

See
http://docs.pylonsproject.org/docs/pyramid/en/latest/api/config.html#module-pyramid.config
to learn more about the config.include method.

main.py
"""
def main(global_config, **settings):
        config = Configurator(settings=settings)
        ...
        config.include('views')
"""

views.py
"""
def home_view(context, request):
    ...

def includeme(config):
    config.add_route("home", "/")
    config.add_view(home_view, route_name="home")
"""



Le 03/10/2014 11:03, Ivan Sergio Borgonovo a écrit :
> Hi,
>
> I've been looking to some of the sample applications around and I've
> never seen any place where views are placed nearby to routes if they
> are not in the same main file.
>
> I'd like to do something similar without having to pass around a
> configurator, or passing it around in an elegant way.
> I've read about includeme but I still haven't found a way to use it to
> obtain what I'd like.
>
> ## main.py ##
> from wsgiref.simple_server import make_server
> from pyramid.config import Configurator
>
> config = Configurator()
> if __name__ == '__main__':
>   config.scan()
>   # do some other stuff with config
>   config.scan('views')
>   app = config.make_wsgi_app()
>   server = make_server('0.0.0.0', 8080, app)
>   server.serve_forever()
>
>
> ## views.py ##
> from pyramid.response import Response
> from pyramid.httpexceptions import HTTPFound
>
> from pyramid.view import view_config
>
> config.add_route('home', '/') # <----
> @viewconfig(route_name="home")
> def home_view(request):
>   return Response('...')
>
> thanks
>  
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to