On Wed, Sep 4, 2013 at 8:07 AM, Mário Idival <[email protected]> wrote:

> Hello,
> I New in Pyramid an have a question:
>
> How i can use others Pyramid projects inside other?
> e.g
>
> I'm create a project with mongobd, have other with management users and
> permissions using postgresql and i want use this two projects in a third
> project...
>
>
> How i can do this?
>
>
You can use paste urlmap to mount different wsgi apps on different mount
points, for example how to do this in your dev.ini:

http://pythonpaste.org/deploy/#the-config-file

or you could just import the wsgi apps and make them as Pyramid views with
wsgiapp2:
http://docs.pylonsproject.org/projects/pyramid/en/master/api/wsgi.html#pyramid.wsgi.wsgiapp2


Or just make a callable WSGI class that uses regex to call the right app:

class CompositeApp(object):
    def __init__(self, global_config, **settings):
        app1_re = re.compile(r'^/?app1(/|$)')
        app2_re = re.compile(r'^/?app2(/|$)')
        app3_re = re.compile(r'^/?app3(/|$)')

        app1 = main_of_app_1({}, settings)
        app2 = main_of_app_2({}, settings)
        app3 = main_of_app_3({}, settings)

        self.app_mapping = (
            (app1_re, app1),
            (app2_re, app2),
            (app3_re, app3)
        )

    def __call__(self, environ, start_response):
        path = environ['PATH_INFO']

        for regex, app in self.app_mapping:
            if regex.match(path) is not None:
                return app(environ, start_response)

-- 
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/groups/opt_out.

Reply via email to