|
|
|
|
File: [home] / webnote / Attic / common-default.py
(download)
/
(as text)
Revision: 1.13, Tue May 31 02:48:56 2005 UTC (5 years, 3 months ago) by ws Branch: MAIN CVS Tags: HEAD Changes since 1.12: +0 -0 lines FILE REMOVED moved to sub directories |
#!/usr/bin/python
import time, os, MySQLdb
isLogging = 0 # should we log to a file? You need to make sure you have the
# right file permissions to use this.
showDebug = 1 # should we show debug info when the backend has a problem?
showJSDebug = 0 # should we show the js debugging box?
NUM_DATES = 11 # 1 less than this is shown in the load previous lists
# need to change in webnote.js too
# we can only log if we have the logging module (python2.3+)
try:
import logging
except ImportError:
isLogging = 0
def getDBH():
return MySQLdb.connect(host = "localhost", user = "user",
passwd = "pass", db = "dbname");
def retMsg(s):
print "Content-type: text/plain\n\n"
print s
# setup the logging object
if isLogging:
logObj = logging.getLogger()
logObj.setLevel(logging.INFO)
logHandler = logging.FileHandler('webnotelog', 'a')
logFormatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
logHandler.setFormatter(logFormatter)
logObj.addHandler(logHandler)
def log(msg):
if isLogging:
logObj.info('%s %s' % (os.environ['HTTP_USER_AGENT'],
msg.replace('\n', '\\n')))
class NoName(Exception):
pass
| tony at ponderer dot org |
Powered by ViewCVS 0.9.2 |