Page 1 of 1

reload ext. doesn't work in python extensions

Posted: 23 Oct 2007, 19:16
by gringo
I changed an extension written in Python, clicked reload ext. and when I try it I get the same effect as if I hadn't clicked on it (it doesn't get reloaded)

Posted: 25 Oct 2007, 18:48
by gringo
I'm unsure on this... Now it seems to check if the syntax is correct but the other day I changed the code and it didn't get refreshed

Posted: 26 Oct 2007, 06:49
by Lapo
It was probably something else :) We use python extensions regularly and reloading works without a hitch

Posted: 26 Oct 2007, 14:31
by gringo
You're right. I found out that I was missing the last patch that it has a file named jysfs so I guess it has something to do with jython. Anyway I updated my SmartFox version and now it works ok.

Posted: 16 Nov 2007, 13:32
by gringo
When I use my extension that refers to a python package, if I change something in the package it doesn't get updated until I restart the service.

Posted: 16 Nov 2007, 14:13
by Lapo
There's a "trick" that you can use to reload the package as well.

Suppose you have a custom class called MyClass inside a module called MyModule. Somewhere in your code you will have a line like this:

Code: Select all

from MyModule import MyClass
in order to reload the module and its classes you should unload it manually in the destroy() method.
Example:

Code: Select all

def destroy():
    import sys
    del sys.modules["MyModule"]
hope it helps

Posted: 16 Nov 2007, 19:47
by gringo
Thank you Lapo! It worked!