Re: [jToolkit-users] Problems with hello world
Brought to you by:
davidfraser,
friedelwolff
|
From: Greenbeard <gre...@ya...> - 2003-10-16 04:22:26
|
Well I figured it out......Here is my log
Removed ALL jtoolkit references
Downloaded the tar.gz this time
used winzip to place tar.gz file to
python\Lib\site-packages
renamed folder from jtoolkit-0.1 to jtoolkit
Restored httpd.conf as shown on webpage
created a folder called jtoolkit in my apache\htdocs
renamed __init__.py in \web to orig_init_.py
copied in the newer __init__.py I received from you
the other day
Restarted APACHE
ERROR>
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 71, in getserver
raise ImportError(errormessage)
ImportError: Error importing module
'jToolkit.demo.helloworld': No module named DateTime
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']
============================================
Ah HA! My mx.DateTime is under
c:\python22\Lib\site-packages\mx\DateTime - As is the
default when you install the mx base package on
Windos. So I copied the DateTime folder from the mx
package to the Site-Packages directory and BINGO
Hello World
Now I do not know why I did not get this error before
but it was definately user error I'm sure. Now we
will see what else I can figure out!
Thanks for your help, I am sure I will be in touch ;->
gb400
--- David Fraser <da...@sj...> wrote:
> 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
> >>
> >>
> >>
>
> > """this is a Hello World-style demonstration
program
> of jToolkit"""
>
> from jToolkit.web import server
> from jToolkit.widgets import widgets
>
> # Copyright 2002, 2003 St James Software
> #
> # This file is part of jToolkit.
> #
> # jToolkit is free software; you can redistribute it
> and/or modify
> # it under the terms of the GNU General Public
> License as published by
> # the Free Software Foundation; either version 2 of
> the License, or
> # (at your option) any later version.
> #
> # jToolkit is distributed in the hope that it will
> be useful,
> # but WITHOUT ANY WARRANTY; without even the implied
> warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE. See the
> # GNU General Public License for more details.
> #
> # You should have received a copy of the GNU General
> Public License
> # along with jToolkit; if not, write to the Free
> Software
> # Foundation, Inc., 59 Temple Place, Suite 330,
> Boston, MA 02111-1307 USA
>
> class HelloWorldServer(server.AppServer):
> """the Server that serves the Hello World Pages"""
> def getpage(self, pathwords, session, argdict):
> """return a page that will be sent to the
> user"""
> return widgets.PlainContents("Hello World")
>
> class HelloWorldConfig:
> """the configuration parameters for a hello world
> server"""
> serverclass = HelloWorldServer
>
>
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
|