trouble with app.yaml url mapping

14 views
Skip to first unread message

iceanfire

unread,
Jul 18, 2008, 3:28:56 PM7/18/08
to Google App Engine
Hey all,

The current url configuration I have works on the sdk, but when I
uploaded it online, the "/manage/profile" part of my script stopped
working (shows a blank page). I'm pretty sure i'm doing something
wrong with my app.yaml url configurations, but I can't figure out how
to fix it (I shuffled a few things here and there but it didn't help).

Here's the applicable app.yaml text for the "manage" portion of my
site:

- url: /manage/profile
script: profile.py
login: required

- url: /manage/profile/.*
script: profile.py
login: required

- url: /manage
script: manage.py
login: required

- url: /manage/.*
script: manage.py
login: required

My guess was that the "/manage" & "/manage/*" were preventing the "/
manage/profile" part from directing appengine to the profile.py file,
so I deleted those two entries and uploaded the update. But nothing
changed! All the urls in /manage (i.e /manage/add/item) which refer to
manage.py work fine.

Also another small problem that I have when I upload is, I get the
following error: Could not guess mimetype for images/favicon.ico.
Using application/octet-stream.

And the favicon doesn't show up as a result.

I'd appreciate some suggestions to fix this..

Thanks!

iceanfire

unread,
Jul 18, 2008, 3:40:56 PM7/18/08
to Google App Engine
here is my main():

def main():
application = webapp.WSGIApplication(
[('/manage/profile', Profile),
('/manage/profile/', Profile),
('/manage/profile/(.*)',
updateProfile),],
debug=True)
wsgiref.handlers.CGIHandler().run(application)

Blixt

unread,
Jul 18, 2008, 3:51:23 PM7/18/08
to Google App Engine
I'd recommend that you use just one script for handling requests,
which then instantiates the appropriate handler. Then you could just
put /.* at the bottom after the static file handlers and direct it to
your main script. Assuming you are using WSGI handlers, it'd be easy
to just use pretty much the same regular expressions to send the
requests to the relevant handlers. It might even make fetching
arguments simpler. A regular expression of '/manager/profile/(.+)'
could be used, then the handler would get whatever's in the (.+) as
its first argument. But I digress.

The handlers look fine to me, and they are in the right order (since
handlers take priority top-to-bottom.)

Here's how I do favicons (you can of course change gif to png if
that's the format you're using for the icon):
- url: /favicon\.ico
mime_type: image/gif
static_files: misc/favicon.gif
upload: misc/favicon\.gif

Regards,
Andreas

iceanfire

unread,
Jul 18, 2008, 4:35:06 PM7/18/08
to Google App Engine
So do you mean that I should just have one .py script that holds all
my classes?
or did you mean that I should have one .py script that only handles
requests and sends them to the appropriate .py file (although I'm not
sure how to do the second one).

Blixt

unread,
Jul 18, 2008, 4:46:57 PM7/18/08
to Google App Engine
It's pretty common in Python to put all related classes in one file
("module".) You can also put them in separate files if you really want
to. To include another file ("import a module"), you do like this (in
the example, the filename would be your_module_name.py):
import your_module_name

Now all variables, functions and classes defined in that module will
be available in your script, but with the prefix "your_module_name":
obj = your_module_name.YourClassInYourModule()

It's up to you how you structure your application, but I try not to
create too many files. I generally only create different files for
when the files can be included separately and still have meaning. If
they always need to be included together, they might as well be in the
same file.

Regards,
Andreas
Reply all
Reply to author
Forward
0 new messages