Ok, I'm confused here. I'm very new to Python aswell, so this probably doesn't help very much. As oppossed to trying to constanly import a huge set of require variables all the time, I thought it might be a good idea to introduce 1 object into the globals space which will host a variety of the functions.

I did this by calling engine.Runtime.Globals.SetVariable("server", server); then loading source script, compile it and invoke it on the scope.
def OnConnect(user):
   global server
   server.log.Write("Test")

However, this results in the same error, where server is not defined. I feel kinda silly here, as to me is would seem rather logical that when I introduce variables into a ScriptScope and then execute a function within that scope that it would work. I understand that variables themselfs are limited to a module, which sounds logical, but it feels weird that even tho I inject a variable directly into the globals table or into the scope that I created before executing a script on it, I can't (in)directly use them from script.

The other solution would be to have the server object be part of every function call to scripts, but that sounds kinda silly...

Patrick

Dino Viehland wrote:
You can set the variables in ScriptRuntime.Globals but then the user
will need to import them from Globals to have access to them.  There's no
way to automatically expose globals to every script though.

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to