Edgewall Software

Ticket #7320: modpython_egg_cache.patch

File modpython_egg_cache.patch, 1.3 KB (added by jonas, 4 years ago)

Set PYTHON_EGG_CACHE using PythonOption?

  • trac/web/__init__.py

     
     1# mod_python specific code that needs to be here in order to 
     2# to be executed before anything is imported. 
     3#  
     4# PYTHON_EGG_CACHE can be set from the apache config file like this: 
     5# 
     6# PythonOption PYTHON_EGG_CACHE /some/path 
     7# 
     8# Important: This option must be placed outside any virtualhost  
     9# and location sections. 
     10# 
     11try: 
     12    from mod_python import apache 
     13    import os 
     14    options = apache.main_server.get_options() 
     15    egg_cache = options.get('PYTHON_EGG_CACHE') 
     16    if egg_cache: 
     17        os.environ['PYTHON_EGG_CACHE'] = egg_cache 
     18except ImportError: 
     19    pass 
     20     
    121from trac.web.api import * 
     22 No newline at end of file 
  • trac/web/modpython_frontend.py

     
    118118 
    119119 
    120120def handler(req): 
    121     egg_cache = req.subprocess_env.get('PYTHON_EGG_CACHE') 
    122     if egg_cache: 
    123         os.environ['PYTHON_EGG_CACHE'] = egg_cache 
    124121    pkg_resources.require('Trac==%s' % VERSION) 
    125122    gateway = ModPythonGateway(req, req.get_options()) 
    126123    from trac.web.main import dispatch_request