CherryPy Project Download

PyLucene: CherrypyPylucene.txt

Line 
1 As described in the tools wiki (http://tools.cherrypy.org/wiki/PyLucene) there is a problem in using PyLucene from CherryPy since PyLucene uses a slightly different Thread class(PyLucene.PythonThread). The wiki suggests to modify the CherryPy source code.
2
3 Here I propose a solution to avoid this (inspired by the dummy_threading module mentioned to me by my colleague RichardPhilips).
4 Import the following code on top of your application, before you import cherrypy. All subsequent 'import threading' commands will import this module and use the PyLucene.PythonThread class. Be sure to replace the 'anet.explorator.exploratorthreading' path by the name and path you give to the module. It is necessary to fill the locals() table with the _names of the threading module since CherryPy addresses some _classes directly (_Timer for example)
5
6
7
8 {{{from threading import *
9 from threading import __all__
10
11 import threading
12 all = dir(threading)
13 for name in all:
14    if name[0] == '_' and name[1] != '_':
15        locals()[name] = eval('threading.%s' % name)
16
17 import sys
18 del sys.modules['threading']
19
20 try:
21    sys.modules['threading'] =
22 sys.modules['anet.explorator.exploratorthreading']
23 except:
24    sys.modules['threading'] = sys.modules['exploratorthreading']
25
26 import PyLucene
27 class Thread(PyLucene.PythonThread):
28    def __init__(self,  *args, **kwds):
29        PyLucene.PythonThread.__init__(self,*args, **kwds)
30 }}}
31
32
33 Marc Jeurissen
34 University of Antwerp
35 marc.jeurissen@ua.ac.be

Hosted by WebFaction

Log in as guest/cherrypy to create/edit wiki pages