coding crime : never use the expression "if obj" whenever obj is not a simple type.

this code was working just by chance because active_knowledge_pad is a brain, not an ERP5 object.
optimise ERP5Site_getKnowledgePadListForUser.

call getObject() once explicitly to reduce number of calls.