Just create a random n-character string for each document. Do that in
put() before the entity is saved for the first time. Choose n based on
what risk of collision (two documents having the same randomly
generated slug) is practical. I say n=6 is pretty good.

On Jan 10, 10:24 am, Jesse Grosjean <je...@hogbaysoftware.com> wrote:
> I'm relatively new to web programming, so don't feel back about
> telling me the obvious :)
>
> I have a simple model consisting of Account entities that can own many
> document entities. I'd like to create a short as possible, globally
> unique URL scheme that I can use to access any document. For testing
> right now I'm just using the documents .key() in the URL. So for
> example my urls look something like this:
>
> /documents/
> ag13cml0ZXJvb20tY29tchwLEgdBY2NvdW50GH4MCxIIRG9jdW1lbnQYiQEM
>
> But that's really long. I'm now trying to figure out the easiest way
> to make it shorter. One option that I'm considering is to just put the
> account id and document id in the URL separated by a dash like this:
>
> /documents/126-137
>
> And then I can reconstruct the Key like this:
>
> db.Key.from_path('Account', account_key, 'Document', document_key)
>
> I haven't actually tried this yet... but I think it should work?
>
> My goal is a unique, short, permanent URL for every document in the
> system. If I'm going about this the wrong way or doing something dumb
> please let me know.
>
> Thanks,
> Jesse
--~--~---------~--~----~------------~-------~--~----~
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