I've been having a similar problem. For me, it came down to the name
of
the import module directory. When the directory was named "test", the
import worked in the SDK (1.1.9) but not online. Renaming the
directory
to "tst" cured the problem. Is "test" some kind of magic word to GAE?

A very simple "helloworld" app (see NOTE 1) demonstrates this. As
written,
it ran correctly in the SDK and online. But after uncommenting this
line
in dispatch.py:

#        import test.helloworld as helloworld

it ran correctly in the SDK but yielded the following error online:

02-28 07:13PM 30.734 / 500 115ms 133ms-cpu 0kb
See details
71.56.163.173 - - [28/Feb/2009:19:13:30 -0800] "GET / HTTP/1.1" 500
347 - -E 02-28 07:13PM 30.837
No module named helloworld
Traceback (most recent call last):
  File "/base/python_lib/versions/1/google/appengine/ext/webapp/
__init__.py", line 501, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/hjk-hjk/1.331753260173090133/
dispatch.py", line 9, in get
    import test.helloworld as helloworld
ImportError: No module named helloworld


This seems too simple to be true. Can someone please show me the error
of
my ways?

- DocDay

NOTE 1:

DIRECTORY STRUCTURE:

helloworld:
    __init__.py
    app.yaml
    dispatch.py
    helloworld.py
    test:
        __init__.py
        helloworld.py
    tst:
        __init__.py
        helloworld.py


CONTENTS OF app.yaml:

application: <appid>
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: dispatch.py


CONTENTS OF dispatch.py:

import wsgiref.handlers
from google.appengine.ext import webapp

class MainHandler(webapp.RequestHandler):

    def get(self):
        import helloworld as helloworld
        import tst.helloworld as helloworld
#        import test.helloworld as helloworld
        self.response.out.write(helloworld.get())

def main():
    application = webapp.WSGIApplication([('.*',
MainHandler)],debug=True)
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
    main()


CONTENTS OF helloworld.py:

def get():
    return 'Hello, World! from root helloworld.py'


CONTENTS OF test/helloworld.py:

def get():
    return 'Hello, World! from test.helloworld.py'


CONTENTS OF tst/helloworld.py:

def get():
    return 'Hello, World! from tst.helloworld.py'

END OF NOTE 1


On Feb 27, 12:55 pm, johntray <john.tur...@gmail.com> wrote:
> OK thanks for the info.
>
> Can I ask you to feed a suggestion back to the GAE documentation
> folks? A sentence or two about not commingling handlers and static
> dirs 
> inhttp://code.google.com/appengine/docs/python/tools/configuration.html...
> would have saved me some grief.
>
> My app has 3 major parts, so I organized it in 3 directories, each
> containing a request handler (python) in the top-level directory, and
> their respective images, javascript, and stylesheets in
> subdirectories. Seems like the most natural layout, however it sounds
> like I *should* have used 2 directories at the root level, one for
> handlers and the other for static files.
>
> Thanks again,
> john
>
> On Feb 27, 12:21 pm, Marzia Niccolai <ma...@google.com> wrote:
>
>
>
> > Hi,
>
> > My guess is that you are having issues because you have site/images, etc as
> > a static_dir, but it seems you also have program files in the site/
> > directory? It's treating the entire site/ directory as a static directory,
> > and thus it is not accessible in your application.
>
> > This is a known issue with the dev_appserver, where static_dir are
> > programmatically accessible through the dev_appserver, but this is not the
> > case in production.
>
> > The solution would be to separate out your static files and program files in
> > to completely different directories.
>
> > -Marzia
>
> > On Thu, Feb 26, 2009 at 6:14 PM, johntray <john.tur...@gmail.com> wrote:
>
> > > Well I am completely stumped. Since upgrading to the 1.1.9 SDK, my app
> > > runs OK with dev_appserver, but when I upload and try to run online, I
> > > get animportmodule error:
>
> > > <type 'exceptions.ImportError'>:No module namedsiterequesthandler
> > > Traceback (most recent call last):
> > >  File "/base/data/home/apps/jatnotes/1.331705598365864096/main.py",
> > > line 7, in <module>
> > >    from site.siterequesthandlerimportSiteRequestHandler
>
> > > Can anyone help me figure out what is wrong here? Since every other
> > > post seems to blame 500 errors on the app.yaml file, I will paste mine
> > > below. (I don't see the connection, but I've got nothing to lose...)
>
> > > john
>
> > > application: jatnotes
> > > version: 1
> > > runtime: python
> > > api_version: 1
>
> > > handlers:
> > > - url: /site/images
> > >  static_dir: site/images
>
> > > - url: /site/stylesheets
> > >  static_dir: site/stylesheets
>
> > > - url: /javascript
> > >  static_dir: html/javascript
> > >  login: required
>
> > > - url: /stylesheets
> > >  static_dir: html/stylesheets
> > >  login: required
>
> > > - url: /test
> > >  static_dir: test
>
> > > - url: /.*
> > >  script: main.py
>
> > > skip_files:
> > > - ^(.*/)?app\.yaml
> > > - ^(.*/)?app\.yml
> > > - ^(.*/)?index\.yaml
> > > - ^(.*/)?index\.yml
> > > - ^(.*/)?#.*#
> > > - ^(.*/)?.*~
> > > - ^(.*/)?.*\.py[co]
> > > - ^(.*/)?.*/RCS/.*
> > > - ^(.*/)?\..*
> > > - ^(.*/)?test/.*         # don't upload test directory (localhost
> > > only)
> > > - ^(.*/)?html/images/.*  # html/images directory not used- Hide quoted 
> > > text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to