Index: autoping.py
===================================================================
--- autoping.py	(revision 1223)
+++ autoping.py	(working copy)
@@ -31,13 +31,9 @@
 
 # Get our pyblosxom specifics here
 from Pyblosxom import tools
-from Pyblosxom.pyblosxom import blosxom_entry_parser
-from Pyblosxom.Request import Request
-import config
+from Pyblosxom.pyblosxom import blosxom_entry_parser,Request,PyBlosxom
+from config import py
 
-logdir = config.get("logdir", "/tmp")
-logfile = os.path.normpath(logdir + os.sep + "autoping.log")
-logger = tools.getLogger()
 
 def excerpt(filename, title, body, blogname):
     """ filename,title,body => url,args
@@ -170,7 +166,6 @@
         except Exception, e:
             logger.error(e)
 
-
 def pingback(parser):
     """ parser -> None
 
@@ -186,19 +181,17 @@
         except Exception, e:
             logger.error(e)
 
-def autoping(name):
-    request = Request()
+def autoping(name, blosxom):
     # Load up the cache (You can just import the base cache here)
-    cache_driver = tools.importName('Pyblosxom.cache', config.py.get('cacheDriver', 'base'))
-    cache = cache_driver.BlosxomCache(request, config.py.get('cacheConfig', ''))
+    request = blosxom.getRequest ()
+    cache = tools.get_cache (request)
     try:
-        filename = os.path.join(config.py['datadir'], name)
+        filename = os.path.join(config['datadir'], name)
         entryData = {}
         cache.load(filename)
         # Look for cached documents
         if cache.isCached():
             entryData = cache.getEntry()
-            
         # Cached? Try our entryparsers then.
         if not entryData:
             fileExt = re.search(r'\.([\w]+)$', filename)
@@ -207,14 +200,42 @@
             except IOError, e:
                 logger.error(e)
         
-        name = re.sub(config.py['datadir'],'',name)
-        parser = link(name, entryData['title'].strip(), entryData['body'].strip(), config.py['blog_title'])
+        name = re.sub(config['datadir'],'',name)
+        parser = link(name, entryData['title'].strip(), entryData['body'].strip(), config['blog_title'])
         trackback(parser)
         pingback(parser)
     except Exception, e:
         logger.error(e)
-    
 
+def getBlosxom (cfg, pathinfo):
+    env = {
+        "HTTP_USER_AGENT": "Pyblosxom autoping",
+        "REQUEST_METHOD": "GET",
+        "HTTP_HOST": "localhost",
+        "PATH_INFO": pathinfo,
+        "QUERY_STRING": "",
+        "REQUEST_URI": pathinfo + "?" + "",
+        "PATH_INFO": pathinfo,
+        "HTTP_REFERER": "",
+        "REMOTE_ADDR": "",
+        "SCRIPT_NAME": "",
+        "wsgi.errors": sys.stderr,
+        "wsgi.input": None
+    }
+    data = {"STATIC": 1}
+    p = PyBlosxom(cfg, env, data)
+    p.run(static=True)
+    return p
+
+blosxom = getBlosxom (py, "")
+config = blosxom.getRequest().getConfiguration ()
+logdir = config.get ('logdir', '/tmp')
+tools.initialize(config)
+logger = tools.getLogger()
+logfile = os.path.normpath(logdir + os.sep + "autoping.log")
+
 if __name__ == '__main__':
     for name in sys.argv[1:]:
-        autoping(name)
+        blosxom = getBlosxom (py, name)
+        config  =  blosxom.getRequest().getConfiguration ()
+        autoping(name, blosxom)
