In almost all uses of
Nonereturn value (missing model) is not handled. This usually leads to a very confusing exception later in other place in the form
AttributeError: 'NoneType' object has no attribute 'xxxxx'.
Sometimes, finding the error cause is not straightforward as the exception does not show the offending model name which may be from XML data or has been dynamically manipulated like in menu actions or just a missing dependency.
To find the problem, I have to set a conditional breakpoint for the None value at the exception line and look up in the stack for the model name.
Registry class has
__getitem__() method, I started to use
self.pool[model] in my code to get an exception that shows the model name immediately in the form
KeyError: 'model.name' instead of a confusing error later.
My question is, why OpenERP server and core modules use the
pool.get() method if the None value is not handled anyway?