On Dec 29, 8:06 am, "Mark Ramm" <[email protected]> wrote:
> The routes package also allows for sub-domain based dispatch, which you can
> use with multiple ObjectDispatchControllers so you have a separate
> controller tree for cars.application.com than you do for
> trucks.application.com
>
> This use case has not been fully explored, and I think we should create a
> simple recipie or two for this, so let us know if there's anything else we
> can do to help.

Cool, so as far as I understand, to use this in TG2 I need override
tg.configuration.AppConfig.setup_routes in my configuration/
app_setup.py and define my own routes like this:

def setup_routes(self):
        map = Mapper(directory=config['pylons.paths']['controllers'],
                    always_scan=config['debug'])
        # Setup a default route for the error controller:
        map.connect('error/:action/:id', controller='error')
        # Setup a default route for the root of object dispatch
        map.connect('*url', controller='root',
action='routes_placeholder', conditions=dict(sub_domain=['www'] )
        # Setup a route for the 'cars' subdomain
        map.connect('*url', controller='cars',
action='routes_placeholder', conditions=dict(sub_domain=['cars'] )
        config['routes.map'] = map
base_config.setup_routes = setup_routes

And then all requests to cars.example.com will go to the
RootController in controllers/cars.py ? I am aware that such
configuration would not serve example.com URLs (without a subdomain),
but I am not sure what is the proper syntax to fix that.

--
Aigars Mahinovs
<[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to