reload ext. doesn't work in python extensions

You think you've found a bug? Please report it here.

Moderators: Lapo, Bax

Post Reply
gringo
Posts: 16
Joined: 11 May 2007, 18:17

reload ext. doesn't work in python extensions

Post 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)
gringo
Posts: 16
Joined: 11 May 2007, 18:17

Post 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
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

It was probably something else :) We use python extensions regularly and reloading works without a hitch
Lapo
--
gotoAndPlay()
...addicted to flash games
gringo
Posts: 16
Joined: 11 May 2007, 18:17

Post 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.
gringo
Posts: 16
Joined: 11 May 2007, 18:17

Post 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.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
gringo
Posts: 16
Joined: 11 May 2007, 18:17

Post by gringo »

Thank you Lapo! It worked!
Post Reply