含有章节索引的中文 文章模板

::-- hoxide [2006-01-09 07:29:23]

1. PyBlosxom Multuser

简述

1.1. 软件环境

  • Windows 2003
  • Python 2.4.1
  • Pyblosxom 1.3 dev
  • Apache 2.0
  • Mod_Python 3.2.5b
  • WSGI ref
  • mp_wsgi_handler

1.2. Apache 设置

<VirtualHost *:8066>
  ServerAdmin [email protected]
  DocumentRoot "g:/pyblog"
  ServerName blog.example.com
  <Location /weblog>
      AddDefaultCharset utf-8
      PythonDebug off
      SetHandler python-program
      # set PythonPath to the folders containing the files.
      PythonPath "['g:/pyblog/myblog']+sys.path"
      PythonHandler mp_wsgi_handler::wsgi_handler
      # This should be the same as the Location above
      PythonOption ApplicationPath /weblog
      PythonOption application wsgi_app::application
   </Location>

</VirtualHost>

1.3. 修改 wsgi_app.py

   1 # Pyblosxom imports
   2 from Pyblosxom.pyblosxom import PyBlosxom
   3 from Pyblosxom import tools
   4 import pprint
   5 from string import find as _find
   6 from config import py as cfg
   7 if cfg.has_key("codebase"):
   8     sys.path.insert(0, cfg["codebase"])
   9 
  10 ...
  11 
  12 def application(env, start_response):
  13 
  14     try: # regular application code here
  15 
  16         # ensure that PATH_INFO exists. a few plugins break if this is missing.
  17         if not 'PATH_INFO' in env:
  18             env['PATH_INFO'] = ""
  19 
  20         username = env['PATH_INFO'].split('/', 2)[1]
  21         cfg['datadir'] = "g:/pyblog/%s/datadir"%username
  22         cfg['comment_dir'] = "g:/pyblog/%s/comments"%username
  23 
  24         #env['SCRIPT_NANE'] = "%s/%s"%(env['SCRIPT_NAME'], username)
  25         env['PATH_INFO'] = env['PATH_INFO'][len(username)+1:]
  26         cfg['base_url'] = '%s://%s%s/%s' % (env['wsgi.url_scheme'], env['HTTP_HOST'], env['SCRIPT_NAME'],username)
  27 
  28         logger = tools.getLogger(logfilename)
  29         logger.debug(pprint.pformat(
  30             dict([(k , v) for k, v in env.items() if k in envdkeys])))
  31 
  32 
  33         p = PyBlosxom(cfg, env)
  34         p.run()