However, a question: Where should I register, when includeme is called, the app in something like registred_apps. Should I just do config.registry.setdefault('registered_apps', []) in the main __init__.py and then append to it from my appIncluder function ? Please advise.
On Sunday, 17 March 2013 01:31:34 UTC+5:30, Anthony Perot wrote: > > I have implemented a global appIncluder function which is imported as > includeme with the *init*.py of the package to be included. > > includeme (appIncluder) receives the config object, so it is then easy to > use config.package and its variables/methods/classes (present in the same > *init*.py and submodules. > > The code: > > project: 'foo' apps to be deployed in foo.foo.apps directory > > Structure: > > foo|-foo > |- __init__.py > |- appincluder.py > |-apps > |-test > |- __init__.py > |- views.py > |- templates > |- test.jinja2 > > foo/foo/*init*.py: > > config.include('foo.apps.test') > > foo/foo/appincluder.py > > def appIncluder(config): > app = config.package > prefix = app.prefix > routes = app.routes > > for route,url in routes.items(): > config.add_route(route,prefix + url) > > config.scan(app) > > log.info('app: %s included' % app.__name__) > > foo/foo/apps/test/*init*.py > > from foo.appincluder import appIncluder as includeme > > prefix = '/test' > > routes = { > 'test': '/home'} > > foo/foo/apps/test/views.py > > from pyramid.view import view_config > > @view_config(route_name='test', renderer='templates/test.jinja2')def > test(request): > return {} > > I hope it helps someone. > -- 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 pylons-discuss+unsubscr...@googlegroups.com. To post to this group, send email to pylons-discuss@googlegroups.com. Visit this group at http://groups.google.com/group/pylons-discuss?hl=en. For more options, visit https://groups.google.com/groups/opt_out.