Here's an untested minimal setup for Pylons minus a few details (like 
imports). Throw in a config file, and this about all you need. I'd be 
interested in seeing an equivalent Pyramid setup.


# config/middleware.py
def make_app(global_conf, full_stack=True, **app_conf):
    config = load_environment(global_conf, app_conf)
    app = PylonsApp(config=config)
    app = RoutesMiddleware(app, config['routes.map'])
    app = RegistryManager(app)
    # auth middleware here if you need it
    return app


# config/environment.py
def load_environment(global_conf, app_conf):
    config = PylonsConfig()
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root, controllers=os.path.join(root, 'controllers'))
    config.init_app(global_conf, app_conf, package='mypkg', paths=paths)
    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config) 
    return config


# config/routing.py
def make_map(config):
    map = Mapper(directory=config['pylons.paths']['controllers'],
                 always_scan=config['debug'])
    map.minimization = False
    map.explicit = False
    map.resource('thing', 'things')
    return map


# controller/things.py
class ThingsController(SomeRESTfulBaseController):
    """Implement/override index, show, create, delete, etc to suit..."""

-- 
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