views:

48

answers:

2

My class looks like this:

class Post(db.Model):
    link = db.LinkProperty()

I am getting the url parameter and populating the class like this:

newpost = Post(
link = cgi.escape(self.request.get('link')))

newpost.put()

If I send a regular link it works fine. If I send a link like this (with a hash): http://www.url.com#paragraph2, it chokes.

Has anyone dealt with this before? Any recommendations would be appreciated.

+4  A: 

The hash component of a URL is never sent to the server.

This behavior is used in some AJAX patterns because of this property.

I would recommend URL-encoding the hash in the URL to %23:

http://example.com/whatever%23afterHash

Ben S
I need to save the complete URL to the database, including the hash. Any suggestions on how to properly escape it so that I get everything saved?
I added my suggestion to URL-encode the hash.
Ben S
A: 

If db.LinkProperty won't work, just use db.StringProperty.

Fh