Ticket #2581: paste-deploy.patch
| File paste-deploy.patch, 3.6 KB (added by ianb@…, 3 years ago) |
|---|
-
setup.py
5 5 import sys 6 6 import string 7 7 from glob import glob 8 from distutils.coreimport setup8 from setuptools import setup 9 9 from distutils.command.install import install 10 10 from distutils.command.install_data import install_data 11 11 from distutils.command.install_scripts import install_scripts … … 234 234 _p('scripts/tracdb2env'), 235 235 _p('cgi-bin/trac.cgi'), 236 236 _p('cgi-bin/trac.fcgi')], 237 entry_points=""" 238 [paste.app_factory] 239 main = trac.web.main:paste_app_factory 240 """, 237 241 cmdclass = {'install': my_install, 238 242 'install_scripts': my_install_scripts, 239 243 'install_data': my_install_data}) -
trac/web/main.py
299 299 req.hdf[key] = val 300 300 301 301 if parent_dir and not env_paths: 302 env_paths = [os.path.join(parent_dir, filename) for filename303 in os.listdir(parent_dir)]302 env_paths = dict([(filename, os.path.join(parent_dir, filename)) for filename 303 in os.listdir(parent_dir)]) 304 304 305 305 projects = [] 306 306 for env_name, env_path in env_paths.items(): … … 314 314 'href': req.href(env_name) 315 315 } 316 316 except Exception, e: 317 proj = {'name': project, 'description': str(e)}317 project = {'name': env_name, 'description': str(e)} 318 318 projects.append(project) 319 319 projects.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower())) 320 320 … … 323 323 req.display(template) 324 324 except RequestDone: 325 325 pass 326 327 328 def check_env_path(name, path): 329 if path is None: 330 return 331 path = os.path.normpath(path) 332 if os.path.abspath(path) != path: 333 raise ValueError, ( 334 "%s must be an absolute directory (use %%(here)s " 335 "to make it relative to the config file): %r" % 336 (name, path)) 337 if not os.path.exists(path): 338 raise ValueError, ( 339 "%s does not exist: %r" % (name, path)) 340 341 def paste_app_factory(global_conf, path=None, 342 paths=None, parent_dir=None): 343 check_env_path('path', path) 344 # XXX: I'm not sure how to handle paths/aka env_paths 345 assert paths is None 346 check_env_path('parent_dir', parent_dir) 347 if not path and not paths and not parent_dir: 348 raise ValueError, ( 349 "You must provide one of path, paths, or parent_dir") 350 def application(environ, start_response): 351 if path is not None: 352 environ['trac.env_path'] = path 353 if paths: 354 environ['trac.env_paths'] = paths 355 if parent_dir: 356 environ['trac.env_parent_dir'] = parent_dir 357 return dispatch_request(environ, start_response) 358 return application -
doc/sample_deploy.ini
1 [app:trac] 2 use = egg:trac 3 # Use path or parent_dir to configure Trac 4 #path = %(here)s/testproj/ 5 parent_dir = %(here)s 6 7 [filter-app:main] 8 # Using this section (#main) will check all responses for WSGI 9 # correctness 10 use = egg:Paste#lint 11 next = trac 12 13 [server:main] 14 # I personally am getting weird behavior with this server, 15 # but wsgiutils is working fine. 16 #use = egg:Paste#http 17 use = egg:PasteScript#wsgiutils 18 host = 127.0.0.1 19 port = 9900
