350
353
exc_traceback = None
355
358
def ReportError(self, etype, evalue, etb, req=None, filter=None, srv=None,
356
359
phase="N/A", hname="N/A", debug=0):
358
This function is only used when debugging is on.
359
It sends the output similar to what you'd see
360
when using Python interactively to the browser
361
This function is only used when debugging is on.
362
It sends the output similar to what you'd see
363
when using Python interactively to the browser
363
365
try: # try/finally
364
366
try: # try/except
412
414
if it has changed since the last import.
416
if sys.modules.has_key(module_name):
418
# The module has been imported already
419
module = sys.modules[module_name]
421
# but is it in the path?
422
file = module.__dict__.get("__file__")
424
# the "and not" part of this condition is to prevent execution
425
# of arbitrary already imported modules, such as os. The
426
# reason we use startswith as opposed to exact match is that
427
# modules inside packages are actually in subdirectories.
429
if not file or (path and not filter(file.startswith, path)):
430
# there is a script by this name already imported, but it's in
431
# a different directory, therefore it's a different script
417
# nlehuen: this is a big lock, we'll have to refine it later to get better performance.
418
# For now, we'll concentrate on thread-safety.
422
if sys.modules.has_key(module_name):
424
# The module has been imported already
425
module = sys.modules[module_name]
427
# but is it in the path?
428
file = module.__dict__.get("__file__")
430
# the "and not" part of this condition is to prevent execution
431
# of arbitrary already imported modules, such as os. The
432
# reason we use startswith as opposed to exact match is that
433
# modules inside packages are actually in subdirectories.
435
if not file or (path and not filter(file.startswith, path)):
436
# there is a script by this name already imported, but it's in
437
# a different directory, therefore it's a different script
438
mtime, oldmtime = 0, -1
440
oldmtime = module.__dict__.get("__mtime__", 0)
441
mtime = module_mtime(module)
443
mtime, oldmtime = 0, 0
432
446
mtime, oldmtime = 0, -1
434
oldmtime = module.__dict__.get("__mtime__", 0)
435
mtime = module_mtime(module)
437
mtime, oldmtime = 0, 0
440
mtime, oldmtime = 0, -1
447
s = "mod_python: (Re)importing module '%s' with path set to '%s'" % (module_name, path)
449
s = "mod_python: (Re)importing module '%s'" % module_name
450
_apache.log_error(s, APLOG_NOERRNO|APLOG_NOTICE)
452
parts = module_name.split('.')
453
for i in range(len(parts)):
454
f, p, d = imp.find_module(parts[i], path)
456
mname = ".".join(parts[:i+1])
457
module = imp.load_module(mname, f, p, d)
460
if hasattr(module, "__path__"):
461
path = module.__path__
464
mtime = module_mtime(module)
466
module.__mtime__ = mtime
448
if mtime != oldmtime:
453
s = "mod_python: (Re)importing module '%s' with path set to '%s'" % (module_name, path)
455
s = "mod_python: (Re)importing module '%s'" % module_name
456
_apache.log_error(s, APLOG_NOERRNO|APLOG_NOTICE)
459
parts = module_name.split('.')
460
for i in range(len(parts)):
461
f, p, d = imp.find_module(parts[i], path)
463
mname = ".".join(parts[:i+1])
464
module = imp.load_module(mname, f, p, d)
466
setattr(parent,parts[i],module)
470
if hasattr(module, "__path__"):
471
path = module.__path__
474
mtime = module_mtime(module)
476
module.__mtime__ = mtime
470
482
def module_mtime(module):
471
483
"""Get modification time of module"""
473
485
if module.__dict__.has_key("__file__"):
475
487
filepath = module.__file__
478
490
# this try/except block is a workaround for a Python bug in
479
491
# 2.0, 2.1 and 2.1.1. See
903
AP_MPMQ_NOT_SUPPORTED = 0 # This value specifies whether
904
# an MPM is capable of
905
# threading or forking.
906
AP_MPMQ_STATIC = 1 # This value specifies whether
932
AP_MPMQ_NOT_SUPPORTED = 0 # This value specifies whether
933
# an MPM is capable of
934
# threading or forking.
935
AP_MPMQ_STATIC = 1 # This value specifies whether
907
936
# an MPM is using a static # of
908
# threads or daemons.
909
AP_MPMQ_DYNAMIC = 2 # This value specifies whether
937
# threads or daemons.
938
AP_MPMQ_DYNAMIC = 2 # This value specifies whether
910
939
# an MPM is using a dynamic # of
911
# threads or daemons.
913
AP_MPMQ_MAX_DAEMON_USED = 1 # Max # of daemons used so far
914
AP_MPMQ_IS_THREADED = 2 # MPM can do threading
915
AP_MPMQ_IS_FORKED = 3 # MPM can do forking
916
AP_MPMQ_HARD_LIMIT_DAEMONS = 4 # The compiled max # daemons
917
AP_MPMQ_HARD_LIMIT_THREADS = 5 # The compiled max # threads
918
AP_MPMQ_MAX_THREADS = 6 # # of threads/child by config
919
AP_MPMQ_MIN_SPARE_DAEMONS = 7 # Min # of spare daemons
920
AP_MPMQ_MIN_SPARE_THREADS = 8 # Min # of spare threads
921
AP_MPMQ_MAX_SPARE_DAEMONS = 9 # Max # of spare daemons
922
AP_MPMQ_MAX_SPARE_THREADS = 10 # Max # of spare threads
923
AP_MPMQ_MAX_REQUESTS_DAEMON= 11 # Max # of requests per daemon
924
AP_MPMQ_MAX_DAEMONS = 12 # Max # of daemons by config
940
# threads or daemons.
942
AP_MPMQ_MAX_DAEMON_USED = 1 # Max # of daemons used so far
943
AP_MPMQ_IS_THREADED = 2 # MPM can do threading
944
AP_MPMQ_IS_FORKED = 3 # MPM can do forking
945
AP_MPMQ_HARD_LIMIT_DAEMONS = 4 # The compiled max # daemons
946
AP_MPMQ_HARD_LIMIT_THREADS = 5 # The compiled max # threads
947
AP_MPMQ_MAX_THREADS = 6 # # of threads/child by config
948
AP_MPMQ_MIN_SPARE_DAEMONS = 7 # Min # of spare daemons
949
AP_MPMQ_MIN_SPARE_THREADS = 8 # Min # of spare threads
950
AP_MPMQ_MAX_SPARE_DAEMONS = 9 # Max # of spare daemons
951
AP_MPMQ_MAX_SPARE_THREADS = 10 # Max # of spare threads
952
AP_MPMQ_MAX_REQUESTS_DAEMON= 11 # Max # of requests per daemon
953
AP_MPMQ_MAX_DAEMONS = 12 # Max # of daemons by config