Edgewall Software

Ticket #2581: paste-deploy.patch

File paste-deploy.patch, 3.6 KB (added by ianb@…, 3 years ago)

Patch

  • setup.py

     
    55import sys 
    66import string 
    77from glob import glob 
    8 from distutils.core import setup 
     8from setuptools import setup 
    99from distutils.command.install import install 
    1010from distutils.command.install_data import install_data 
    1111from distutils.command.install_scripts import install_scripts 
     
    234234               _p('scripts/tracdb2env'), 
    235235               _p('cgi-bin/trac.cgi'), 
    236236               _p('cgi-bin/trac.fcgi')], 
     237      entry_points=""" 
     238      [paste.app_factory] 
     239      main = trac.web.main:paste_app_factory 
     240      """, 
    237241      cmdclass = {'install': my_install, 
    238242                  'install_scripts': my_install_scripts, 
    239243                  'install_data': my_install_data}) 
  • trac/web/main.py

     
    299299            req.hdf[key] = val 
    300300 
    301301    if parent_dir and not env_paths: 
    302         env_paths = [os.path.join(parent_dir, filename) for filename 
    303                      in os.listdir(parent_dir)] 
     302        env_paths = dict([(filename, os.path.join(parent_dir, filename)) for filename 
     303                          in os.listdir(parent_dir)]) 
    304304 
    305305    projects = [] 
    306306    for env_name, env_path in env_paths.items(): 
     
    314314                'href': req.href(env_name) 
    315315            } 
    316316        except Exception, e: 
    317             proj = {'name': project, 'description': str(e)} 
     317            project = {'name': env_name, 'description': str(e)} 
    318318        projects.append(project) 
    319319    projects.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower())) 
    320320 
     
    323323        req.display(template) 
    324324    except RequestDone: 
    325325        pass 
     326 
     327 
     328def 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 
     341def 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] 
     2use = egg:trac 
     3# Use path or parent_dir to configure Trac 
     4#path = %(here)s/testproj/ 
     5parent_dir = %(here)s 
     6 
     7[filter-app:main] 
     8# Using this section (#main) will check all responses for WSGI  
     9# correctness 
     10use = egg:Paste#lint 
     11next = 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 
     17use = egg:PasteScript#wsgiutils 
     18host = 127.0.0.1 
     19port = 9900