Hello!

Let's say I got few pylons apps:

Main:
/srv/approuter + approuter.ini

Various:
/srv/app1 + app1.ini + simplecms main module
/srv/app2 + app2.ini + simplecms main module
/srv/app3 + app3.ini + simplecms main module

These apps are modified version of some other app - CMS with different
modules enabled, depending on my client's request.

What I wanted to is to be able to have my main app routing request
based on domain. So if user connects to my server via something.example.com
then app is going to route him to app1. If he connects to
helloworld.example.com then app is going to route him to app2.

I don't want to start different servers via paster (for a now it's paster)
Also I'd like to have these domains informations being kept in database
and I also want to be able to suspend client's account if he forget to
pay... again and again.

So, here's my simple middleware:

# ------------------------------------------------------------------------
import approuter.config.middleware
import paste.deploy
import os, sys
 from approuter import model


class AppRouter(object):
     """
     App Router.
     """

     def __init__(self, app):
         self.app = app

     def __call__(self, environ, start_response):
         domain = environ.get('HTTP_HOST', None)
         if domain is None:
             return self.app(environ, start_response)

         # Get application object
         app_obj = model.Application.by_domain(domain)
         if not app_obj:
             return self.app(environ, start_response)

         app = app_obj[0] # FIXME, temp

         # My first try to get rid of DistributionNotFound exception
         if app not in sys.path:
             sys.path.append(app.path)  # app path is a path like /srv/app1

         # Get config
         conf_filename = os.path.join(app.path, app.config)
         conf = paste.deploy.appconfig('config:' + conf_filename)

         middle_app = approuter.config.middleware.make_app(conf, full_stack  
= True)
        # My second try to get rid of DistributionNotFound exception
         middle_app.config.environment.load_environment(conf.global_conf,  
conf.local_conf)
         return middle_app(environ, start_response)
# ------------------------------------------------------------------------

Now let's say my cms app is called simplecms. When I open browser with  
domain
of /srv/app1, I got "DistributionNotFound: simplecms" exception.

Do you have any clue what I am missing?


        MG.
-- 
                                                 /\
  email  [email protected]             /|_/|//\)
   jid    [email protected]             = , , =
   www    http://ascii-art.pl       fsc  ((,)7(,))

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to