Add check to make sure object_id is filled in when content_type is assigned.
This prevents a situation where new objects of that content_type automatically
get those containers assigned to it, since that object then has the id None
just like object_id. Also remove redundant username function from Sample.