0

I'd like to save an object's pointer to the database so that it can be run again later.

The way I see it, I need to know how I can import it before I can run it. Then, I can do some dynamic importing with __import__().

However I'm not sure how, given an arbitrary instantiated object, how do I resolve its import hierarchy.

For example:

I have a Base class imported this way:

from action.base_model import Base

Then I want to save this to a database:

save_task(Base, *args)

But I need to resolve "action.base_model.Base" from the object passed into save_task. How can I do this?

Thanks!

4

0 回答 0