python isinstance gives different results in shell and wsgi

246 views Asked by At

I have encountered a strange problem in which the same object(agent), when checking if it is an instance of a class(Agents), returns True in the shell, but False in the wsgi server.

in the python shell:

In [78]: agent = Agents.by_id(566) # SQLAlchemy Table object

In [79]: type(agent)
Out[79]: models.Prepaid.Agents

In [80]: type(Agents)
Out[80]: sqlalchemy.ext.declarative.api.DeclarativeMeta

In [81]: isinstance(agent, Agents)
Out[81]: True

but when I print the same in my code - to print in the wsgi instance, it looks like:

# print type(agent)
<class 'models.Prepaid.Agents'>
# print type(Agents)
<class 'sqlalchemy.ext.declarative.api.DeclarativeMeta'>
# isinstance(agent, Agents)
False

This is confusing, and I do not know why this is happening.

  • Can someone please explain this?
  • Am I doing something wrong??
0

There are 0 answers