Re: [jToolkit-users] Problems with hello world
Brought to you by:
davidfraser,
friedelwolff
From: David F. <da...@sj...> - 2003-10-15 06:16:16
|
Greenbeard wrote: >OK, >I replaced the __init__.py and now when Apache >Restarts I get: >--------------------------- >Mod_python error: "PythonHandler jToolkit.web" > >Traceback (most recent call last): > > File "C:\Python22\Lib\mod_python\apache.py", line 335, in HandlerDispatch > result = object(req) > > File "C:\Python22\Lib\site-packages\jToolkit\web\__init__.py", line 93, in handler > server = getserver(modulename, instancename) > > File "C:\Python22\Lib\site-packages\jToolkit\web\__init__.py", line 67, in getserver > module = __import__(modulename, globals(), locals(), [instancename]) > > File "C:/Program Files/Apache Group/Apache2/htdocs/\jtoolkit\demo\helloworld.py", line 24, in ? > class HelloWorldServer(server.AppServer): > > File "C:/Program Files/Apache Group/Apache2/htdocs/\jtoolkit\demo\helloworld.py", line 26, in HelloWorldServer > serverclass = HelloWorldServer > >NameError: name 'HelloWorldServer' is not defined >======================== > > This is the real problem, I'll explain below about the other stuff... Basically it looks like your helloworld.py is corrupted. the line "serverclass = HelloWorldServer" should be line 32, it seems lines 26-31 have been deleted... I have attached the correct version as it's small, can you confirm that you are using this exact file... >However, If I refresh the page I get > >Mod_python error: "PythonHandler jToolkit.web" > >Traceback (most recent call last): > > File "C:\Python22\Lib\mod_python\apache.py", line 335, in HandlerDispatch > result = object(req) > > File "C:\Python22\Lib\site-packages\jToolkit\web\__init__.py", line 93, in handler > server = getserver(modulename, instancename) > > File "C:\Python22\Lib\site-packages\jToolkit\web\__init__.py", line 78, in getserver > raise AttributeError(errormessage) > >AttributeError: module 'demo.helloworld' has no attribute 'HelloWorldConfig' >module is <module 'demo.helloworld' from 'C:/Program Files/Apache Group/Apache2/htdocs/jtoolkit/\demo\helloworld.pyc'>, >attributes are ['__builtins__', '__doc__', '__file__', '__name__', 'server', 'widgets'] >Python path is ['C:/Program Files/Apache Group/Apache2/htdocs/jtoolkit/\\', 'C:/Program Files/Apache Group/Apache2/htdocs/\\', 'C:\\Python22\\Lib\\site-packages\\Pythonwin', 'C:\\Python22\\Lib\\site-packages\\win32', 'C:\\Python22\\Lib\\site-packages\\win32\\lib', 'C:\\Python22\\Lib\\site-packages', 'C:\\Python22\\Lib', 'C:\\Python22\\DLLs', 'C:\\Python22\\Lib\\lib-tk', 'C:\\Program Files\\Apache Group\\Apache2', 'C:\\Program Files\\Apache Group\\Apache2\\bin', 'C:\\Python22'] >======= > > OK, the problem here is that once the initial import error has occured (above), mod_python thinks the module has already been imported, so doesn't re-import it. But because it hasn't been imported correctly, it doesn't have the right attributes... >Ok, well I had to tweak the httpd.conf to get this far >look like ><Directory "C:\\Program Files\\Apache Group\\Apache2\\htdocs\\jtoolkit"> > SetHandler python-program > PythonHandler jToolkit.web > #PythonOption jToolkit.module jtoolkit.demo.helloworld > PythonOption jToolkit.module demo.helloworld > PythonOption jToolkit.instance HelloWorldConfig > PythonDebug On > ></Directory> > > Right, so you've set it up so you don't need the jToolkit prefix... BTW I would usually set this up so jToolkit is in the Python path itself rather than under Apache htdocs, but that's not the source of the error here (you should be able to get it to work like this) >So, I went interactive on this and here is what I got: > > >>>>from demo import helloworld >>>> >>>> >Traceback (most recent call last): > File "<interactive input>", line 1, in ? > File "C:\PYTHON22\LIB\SITE-PACKAGES\JTOOLKIT\demo\helloworld.py", line 24, in ? > class HelloWorldServer(server.AppServer): > File "C:\PYTHON22\LIB\SITE-PACKAGES\JTOOLKIT\demo\helloworld.py", line 26, in HelloWorldServer > serverclass = HelloWorldServer >NameError: name 'HelloWorldServer' is not defined > > Again, this shows that the error is in demo.helloworld >>>>import demo >>>>dir(demo) >>>> >>>> >['__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'helloworld'] > > >>>>from demo import helloworld >>>>dir(helloworld) >>>> >>>> >['__builtins__', '__doc__', '__file__', '__name__', 'server', 'widgets'] > > > >So I think I must have something configured >incorrectly in either my httpd.conf or PYTHONPATH. >Could it be my python version? > > No, as I said above, your copy of helloworld.py seems wrong which is strange. >Perhaps I should just start over. Let me know if you >have any ideas. I hate to waste your time. > > Not a waste of time at all, it's good to have the feedback. >I have access to an openBSD server that I may try >installing this on. My problem there is that I >usually have to set the python path in the >application. (or I just dont know how to set it on >openBSD yet. ) > > The best way I find is either to install jToolkit so it is in the Python Path already (if you have appropriate rights) or you can set PythonPath from the .htaccess file (see the modpython docs) Let me know what happens with this... David > >--- David Fraser <da...@sj...> wrote: > > >>Greenbeard wrote: >> >> >> >>>Hello there >>> >>>I am running Win2k, Python 2.2, on Apache2 , mod_py 3.0.1 >>> >>>I extracted the archive to site-packages and changed >>> >>> >>>the httpd.conf as shown in your homepage. I get: >>>----------------------------------------------- >>>Mod_python error: "PythonHandler jToolkit.web" >>> >>>Traceback (most recent call last): >>> >>> File "C:\Python22\Lib\mod_python\apache.py", line 335, in HandlerDispatch >>> result = object(req) >>> >>> File "C:\Python22\Lib\site-packages\jToolkit\web\__init__.py", >>> >>> >>>line 72, in handler >>> instance = getattr(module, instancename) >>> >>>AttributeError: 'module' object has no attribute 'HelloWorldConfig' >>> >>>----------------------------------------------- >>>Here is httpd.conf >>> >>><Directory "C:/Program Files/Apache Group/Apache2/htdocs/jtoolkit"> >>>SetHandler python-program >>>PythonHandler jToolkit.web >>>PythonOption jToolkit.module jToolkit.demo.helloworld >>> >>> >>>PythonOption jToolkit.instance HelloWorldConfig >>>PythonDebug On >>> >>></Directory> >>> >>> >>>TIA, >>> >>>gb400 >>> >>> >>> >>> >>Hi >> >>Thanks for reporting this, this shouldn't happen, but hopefully we'll be >>able to track it down... >>I have attached a modified version of jToolkit\web\__init__.py (this is >>now in jToolkit CVS). >>You should be able to save it over the __init__.py in >> >>C:\Python22\Lib\site-packages\jToolkit\web\__init__.py >> >> >>This should give you a more detailed error message saying which >>attributes are present in the imported module: >> >>Mod_python error: "PythonHandler jToolkit.web" >> >>Traceback (most recent call last): >> >> File "usr/local/python22nothreads/lib/python2.2/site-packages/mod_python/apache.py", line 193, in Dispatch >> result = object(req) >> >> File "share/sjsoft/code/jSuite.py/jToolkit/web/__init__.py", line 84, in handler >> server = getserver(modulename, instancename) >> >> File "/share/sjsoft/code/jSuite.py/jToolkit/web/__init__.py", line 69, in getserver >> raise AttributeError("module %r has no attribute %r\nmodule is %r, attributes are %r" % (modulename, instancename, module, dir(module))) >> >>AttributeError: module 'jToolkit.demo.helloworld' has no attribute 'HelloWorldConfIg' >>module is <module 'jToolkit.demo.helloworld' from '/share/sjsoft/code/jSuite.py/jToolkit/demo/helloworld.pyc'>, >>attributes are ['HelloWorldConfig', 'HelloWorldServer', '__builtins__', '__doc__', '__file__', '__name__', 'server', 'widgets'] >>Python path is ['/share/sjsoft/code/jSuite.py/', '/usr/local/python22nothreads/lib/python2.2/', '/usr/local/python22nothreads/lib/python2.2/site-packages'] >> >>Something else that might be helpful is to try the following from python: >>from jToolkit.demo import helloworld >>dir(helloworld) >>print helloworld.HelloWorldConfig >> >>Let me know the results you find! Thanks for helping to test the package >> >>Regards >>David >> >>PS Soon jToolkit should have the ability to run in a standalone mode >>without mod_python or Apache, which should make testing and initial >>setup easier >> >> >> |