The changes made in the spaces.py file, regarding the mostcommented field, have a serious bug


In the line : context['mostcommented'] = [top_posts.get(id,None) for id in post_ids]

post_ids is a list that contains all the posts that have been made, in all the spaces combined.
top_posts however has been filtered for the current space.
This means that whenever .get method would find an id that exists in some space other than the current space( which automatically exists in the post_ids ), it would return a None, that would get appended to the list, hence the context['mostcommented'] would have a None in it as one of its element.
This would cause an error.

However, if we simply do a .values on the dictionary that contains the posts specific to the current space, we would not get any None element in the context['mostcommented'].

Example:

Suppose we have two spaces called spaceone and spacetwo, now we also have two comments, one in each of them.
Suppose we are currently inside spacetwo:

	the post_ids ==[1,2]
	top_posts={=2:<post: hello>}
	Now if we do a .get on top_posts with id==1 from post_ids, we would be returned a default value = None.
	so the context['mostcommented']==[None,<post:hello>]


However the .values method would just return
	context['mostcommented']=[<post:hello>]
	because it hasn't enquired for post_id==1, which belongs to another space and has already been filtered out in top_posts


Refer to lines 140-165 in spaces.py for clearer understanding of the issue.


Also, this doesn't solve the mostcommented thing, as even now , the comments aren't sorted, I'll do that as soon as I get some time.