Bugs item #2794073, was opened at 2009-05-20 00:45
Message generated for change (Comment added) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2794073&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Oleg Broytmann (phd)
Summary: SqlObject fails in mod_python because of KeyError
Initial Comment:
A simple python handler in apache which uses sqlobject fails because of a KeyError.
sqlobject/main.py in line 762:
mod = sys.modules[cls.__module__]
Uncommenting the lines makes sqlobject work as intended.
Attached is the test script and the debug output from the script when run as a mod_python handler.
I do not have the error when running test scripts in the console. I am guessing it must be something that mod_python is doing when importing sqlobject.
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2009-05-23 21:12
Message:
How can I detect if SQLObject is running under mod_python? Is there
something in sys? os.environ? Can you look it up in mod_python docs? The
solution would be something like this:
if not connection and not getattr(cls, '_connection', None) and \
not running_under_modpython():
mod = sys.modules[cls.__module__]
# See if there's a __connection__ global in
# the module, use it if there is.
if hasattr(mod, '__connection__'):
connection = mod.__connection__
I would like to ask you to find out what 'running_under_modpython' is,
test it and send to me.
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-23 21:01
Message:
uncommenting = commenting them out
Sorry, overlooked the real question!
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-23 20:59
Message:
Well by "uncommenting the lines" I meant line 762 and the ones around it so
that the main.py of sqlobject is still valid.
The lines are the following:
>>>
if not connection and not getattr(cls, '_connection', None):
mod = sys.modules[cls.__module__]
# See if there's a __connection__ global in
# the module, use it if there is.
if hasattr(mod, '__connection__'):
connection = mod.__connection__
<<<
The final error in the mod_python error log is:
>>>
File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 762, in
__classinit__
mod = sys.modules[cls.__module__]
KeyError: '_mp_32178831045d61a426cfbf437900de0b'
<<<
For me this means that cls.__module__ is equal to
'_mp_32178831045d61a426cfbf437900de0b' and it can not be found in the
sys.modules hash/array. I am guessing that is because of some magic that
mod_python is doing to allow caching/reloading of modules.
I am not sure if there is another way to find out if there is a connection
global but the way it is now does not work with mod_python.
I am sorry that I can not offer a real patch or fix but I am a novice
concerning python.
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2009-05-20 01:00
Message:
Uncommenting what lines? Do you mean commenting them out? SQLObject uses
mod to find out a global __connection__ declaration.
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-20 00:49
Message:
Sorry about submitting to early - Here is the bug report:
--------
MOD_PYTHON ERROR
ProcessId: 4361
Interpreter: 'huge.dino.park'
ServerName: 'huge.dino.park'
DocumentRoot: '/var/www/'
URI: '/~michael/test.py'
Location: None
Directory: '/home/michael/public_html/'
Filename: '/home/michael/public_html/test.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line
204, in handler
module = page_cache[req]
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1059, in __getitem__
return import_module(req.filename)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
296, in import_module
log, import_path)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
680, in import_module
execfile(file, module.__dict__)
File "/home/michael/public_html/test.py", line 7, in <module>
class News(sqlobject.SQLObject):
File "/usr/lib/python2.5/site-packages/sqlobject/declarative.py", line
92, in __new__
cls.__classinit__(cls, new_attrs)
File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 762, in
__classinit__
mod = sys.modules[cls.__module__]
KeyError: '_mp_32178831045d61a426cfbf437900de0b'
MODULE CACHE DETAILS
Accessed: Tue May 19 22:40:42 2009
Generation: 0
_mp_32178831045d61a426cfbf437900de0b {
FileName: '/home/michael/public_html/test.py'
Instance: 1 [IMPORT]
Generation: 0 [ERROR]
Modified: Tue May 19 22:35:34 2009
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2794073&group_id=74338

Bugs item #2794073, was opened at 2009-05-19 22:45
Message generated for change (Comment added) made by cv_student
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2794073&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Oleg Broytmann (phd)
Summary: SqlObject fails in mod_python because of KeyError
Initial Comment:
A simple python handler in apache which uses sqlobject fails because of a KeyError.
sqlobject/main.py in line 762:
mod = sys.modules[cls.__module__]
Uncommenting the lines makes sqlobject work as intended.
Attached is the test script and the debug output from the script when run as a mod_python handler.
I do not have the error when running test scripts in the console. I am guessing it must be something that mod_python is doing when importing sqlobject.
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-23 19:01
Message:
uncommenting = commenting them out
Sorry, overlooked the real question!
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-23 18:59
Message:
Well by "uncommenting the lines" I meant line 762 and the ones around it so
that the main.py of sqlobject is still valid.
The lines are the following:
>>>
if not connection and not getattr(cls, '_connection', None):
mod = sys.modules[cls.__module__]
# See if there's a __connection__ global in
# the module, use it if there is.
if hasattr(mod, '__connection__'):
connection = mod.__connection__
<<<
The final error in the mod_python error log is:
>>>
File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 762, in
__classinit__
mod = sys.modules[cls.__module__]
KeyError: '_mp_32178831045d61a426cfbf437900de0b'
<<<
For me this means that cls.__module__ is equal to
'_mp_32178831045d61a426cfbf437900de0b' and it can not be found in the
sys.modules hash/array. I am guessing that is because of some magic that
mod_python is doing to allow caching/reloading of modules.
I am not sure if there is another way to find out if there is a connection
global but the way it is now does not work with mod_python.
I am sorry that I can not offer a real patch or fix but I am a novice
concerning python.
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2009-05-19 23:00
Message:
Uncommenting what lines? Do you mean commenting them out? SQLObject uses
mod to find out a global __connection__ declaration.
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-19 22:49
Message:
Sorry about submitting to early - Here is the bug report:
--------
MOD_PYTHON ERROR
ProcessId: 4361
Interpreter: 'huge.dino.park'
ServerName: 'huge.dino.park'
DocumentRoot: '/var/www/'
URI: '/~michael/test.py'
Location: None
Directory: '/home/michael/public_html/'
Filename: '/home/michael/public_html/test.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line
204, in handler
module = page_cache[req]
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1059, in __getitem__
return import_module(req.filename)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
296, in import_module
log, import_path)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
680, in import_module
execfile(file, module.__dict__)
File "/home/michael/public_html/test.py", line 7, in <module>
class News(sqlobject.SQLObject):
File "/usr/lib/python2.5/site-packages/sqlobject/declarative.py", line
92, in __new__
cls.__classinit__(cls, new_attrs)
File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 762, in
__classinit__
mod = sys.modules[cls.__module__]
KeyError: '_mp_32178831045d61a426cfbf437900de0b'
MODULE CACHE DETAILS
Accessed: Tue May 19 22:40:42 2009
Generation: 0
_mp_32178831045d61a426cfbf437900de0b {
FileName: '/home/michael/public_html/test.py'
Instance: 1 [IMPORT]
Generation: 0 [ERROR]
Modified: Tue May 19 22:35:34 2009
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2794073&group_id=74338

Bugs item #2794073, was opened at 2009-05-19 22:45
Message generated for change (Comment added) made by cv_student
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2794073&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Oleg Broytmann (phd)
Summary: SqlObject fails in mod_python because of KeyError
Initial Comment:
A simple python handler in apache which uses sqlobject fails because of a KeyError.
sqlobject/main.py in line 762:
mod = sys.modules[cls.__module__]
Uncommenting the lines makes sqlobject work as intended.
Attached is the test script and the debug output from the script when run as a mod_python handler.
I do not have the error when running test scripts in the console. I am guessing it must be something that mod_python is doing when importing sqlobject.
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-23 18:59
Message:
Well by "uncommenting the lines" I meant line 762 and the ones around it so
that the main.py of sqlobject is still valid.
The lines are the following:
>>>
if not connection and not getattr(cls, '_connection', None):
mod = sys.modules[cls.__module__]
# See if there's a __connection__ global in
# the module, use it if there is.
if hasattr(mod, '__connection__'):
connection = mod.__connection__
<<<
The final error in the mod_python error log is:
>>>
File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 762, in
__classinit__
mod = sys.modules[cls.__module__]
KeyError: '_mp_32178831045d61a426cfbf437900de0b'
<<<
For me this means that cls.__module__ is equal to
'_mp_32178831045d61a426cfbf437900de0b' and it can not be found in the
sys.modules hash/array. I am guessing that is because of some magic that
mod_python is doing to allow caching/reloading of modules.
I am not sure if there is another way to find out if there is a connection
global but the way it is now does not work with mod_python.
I am sorry that I can not offer a real patch or fix but I am a novice
concerning python.
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2009-05-19 23:00
Message:
Uncommenting what lines? Do you mean commenting them out? SQLObject uses
mod to find out a global __connection__ declaration.
----------------------------------------------------------------------
Comment By: damike (cv_student)
Date: 2009-05-19 22:49
Message:
Sorry about submitting to early - Here is the bug report:
--------
MOD_PYTHON ERROR
ProcessId: 4361
Interpreter: 'huge.dino.park'
ServerName: 'huge.dino.park'
DocumentRoot: '/var/www/'
URI: '/~michael/test.py'
Location: None
Directory: '/home/michael/public_html/'
Filename: '/home/michael/public_html/test.py'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'mod_python.publisher'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.5/site-packages/mod_python/publisher.py", line
204, in handler
module = page_cache[req]
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1059, in __getitem__
return import_module(req.filename)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
296, in import_module
log, import_path)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
680, in import_module
execfile(file, module.__dict__)
File "/home/michael/public_html/test.py", line 7, in <module>
class News(sqlobject.SQLObject):
File "/usr/lib/python2.5/site-packages/sqlobject/declarative.py", line
92, in __new__
cls.__classinit__(cls, new_attrs)
File "/usr/lib/python2.5/site-packages/sqlobject/main.py", line 762, in
__classinit__
mod = sys.modules[cls.__module__]
KeyError: '_mp_32178831045d61a426cfbf437900de0b'
MODULE CACHE DETAILS
Accessed: Tue May 19 22:40:42 2009
Generation: 0
_mp_32178831045d61a426cfbf437900de0b {
FileName: '/home/michael/public_html/test.py'
Instance: 1 [IMPORT]
Generation: 0 [ERROR]
Modified: Tue May 19 22:35:34 2009
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=2794073&group_id=74338