views:

118

answers:

4

how does stackoverflow manage permalinks. For example an arbitary qn like: http://stackoverflow.com/questions/1002230/asp-net-jquery-dynamically-created-hyperlink-controls In this case what happens if the same user posts another qn with the same title. I think the number before- /1002230/ is the key but on what basis is that created. Is it an indicator of how many questions there are in stackoverflow.

This doubt is relevant to me because i am trying to use the title of a blogpost in the permanent link for it. However this won't allow for multiple blogpost with the same title. Neither do i want to use id number. I am infact using appengine for this app so the generated key is something like 'ahVzYW5qaGFjaG9vbGhhLXNhbmRib3hyCwsSBUFjdG9uGFUM' which is surely not nice. So any hints on how to prettify my url Thanks

+2  A: 

The number is the question id which is unique - they only increment and are not reused. The human-readable string is ignored by the server when you retrieve the page by URL - it's for convenience and pretty look - to solve the same task you have. So each question URL has two parts - the machine-readable (the starting part and the question id) and the human-readable - the filtered question title afterwards.

With the exclusion of deleted questions the number is the total number of questions on the site. Numbers of the deleted questions are not reused, so no conflict is possible.

sharptooth
I think it's the number of *posts*, not just questions
hasen j
A: 

The ID number does give some indication of how many total posts there are. I believe I recall from a podcast that both questions and answers are stored as 'posts', but comments may be posts as well.

John Sheehan
+2  A: 

Rather than using the Key().str(), it might be nicer to use the Key's id or key_name with Model.get_by_id() or Model.get_by_key_name(). These are both more user friendly (integer or supplied string respectively).

Jonathan Maddison
A: 

The approach I like best is to use URLs formatted as "/1234/slug-goes-here" (like StackOverflow) or "/1234-slug-goes-here". With a little cleverness, you can ignore the content of the slug, and fetch based on the ID only, which means that links work even if they were truncated by mail software, IRC, etc.

The other approach, App Engine wise, is to use key names - make the slug the key name, which means you can look it up with MyModel.get_by_key_name(slug). This is how Bloog does it.

Nick Johnson