Python OOP Problem

Миклухо mikluxo at gmail.com
Tue Dec 29 09:22:35 EST 2009


On Dec 29, 7:35 pm, Laszlo Nagy <gand... at shopzeus.com> wrote:
> > Thanks for reply, but it doesn't fit to my task. If I will add later
> > other objects(and it will be very often) - I should stop the service,
> > but that would be very bad.
>
> I think you meant "if you add other classes".> I'm not sure, if this is solution, but test passed:
>
> > myimportmod = __import__('ClassName', globals(), locals(),
> > ['ClassName'], -1)
> > mod = getattr(_myimportmod, 'ClassName')
> > o = mod();
> > o.myfunction();
>
> The same way you can say: this won't work if you need to change your
> 'ClassName' class. That would require restart of your service. Then you
> can use reload(). However, I do not see the big picture. What is your
> program suppose to do?
>
>   L

The program works under apache(mod_wsgi) and receives different
messages, depends upon the message it should give an answer. There are
a lot types of messages(something like service) - and if I change a
'ClassName' class(mostly I don't change - just throw away from db note
about it(if time of service ended))- other modules(for instance
ClassName2 ClassName3 etc.) work. And if I will edit the main class
(which loads them) all services may be down. That's why it is
important to make a generalized loader - which loads another class.



More information about the Python-list mailing list