diff --git a/product/ZSQLCatalog/SearchText/lexer.py b/product/ZSQLCatalog/SearchText/lexer.py
index d4eb60fd09b421a91faedfe415fa440e5964f6ec..1a9b2f658af068a7ac85c86bef911c2d547d4336 100644
--- a/product/ZSQLCatalog/SearchText/lexer.py
+++ b/product/ZSQLCatalog/SearchText/lexer.py
@@ -37,7 +37,8 @@ except ImportError:
   def LOG(channel, level, message):
     print >>sys.stderr, message
 
-module_path = os.path.dirname(os.path.abspath(__file__))
+outputdir = os.environ.get('TMPDIR', None) or \
+  os.path.dirname(os.path.abspath(__file__))
 
 class ParserOrLexerError(Exception):
   pass
@@ -57,7 +58,7 @@ class lexer(object):
     self.parser = yacc.yacc(module=self, debug=debug,
                             debugfile="%s.out" % (self.__class__.__name__, ),
                             tabmodule="%s_parsetab" % (self.__class__.__name__, ),
-                            outputdir=module_path)
+                            outputdir=outputdir)
     sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
     # Emit all logs with regular Zope logging
     for line in output.getvalue().split('\n'):