You can create the DataSeries object for them and include it in each call?  Or 
can you do something like:

def Init():
                return DataSeries()

and only call their Init function once?

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of R. Bear Smith
Sent: Monday, March 02, 2009 12:38 PM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] CustomSymbolDictionary question

What I am trying to do is run a user script over and over.  Each time it runs 
there will be different data in the object model that they access to compute 
there values and such.  The trick is they need to be able to access values from 
prior runs.  So the way I have addressed this is they create a c# class called 
DataSeries, I maintain state on it behind the scenes as to what run they are 
on, then they can use an indexer on it to get prior values. so

x = DataSeries()

do some calculations
x.set(somevalue)

// then on the next run of the script they can
y = x[1]   // which gives them access to the value of x from the prior scope 
run.

accessing prior values is required for what the user is doing and while there 
are many ways to code it, keeping it very simple for the users is a priority.  
Hope that helps

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of Jimmy Schementi
Sent: Monday, March 02, 2009 3:10 PM
To: Discussion of IronPython
Subject: Re: [IronPython] CustomSymbolDictionary question

So, if I understand this right, you have user code, which you need to run each 
time first ... and then your code which you want to run once after. Something 
like:

// when your app starts, or something, compile your code, but don't run yet
var compiledCode = engine.CreateScriptSourceFromString(code).Compile();

// do other stuff ....

// execute user code
var userScope = engine.ExecuteFile("usercode.py");

// run your code in the user's code's scope
compiledCode.Execute(userScope);

From: users-boun...@lists.ironpython.com 
[mailto:users-boun...@lists.ironpython.com] On Behalf Of R. Bear Smith
Sent: Monday, March 02, 2009 11:54 AM
To: users@lists.ironpython.com
Subject: [IronPython] CustomSymbolDictionary question

Hi all,

I have a situation where I need to run a script many times with a different 
scope each time.  I want to be able to substitute an instance of a class each 
time it is asked for.   For example,

x = MyCSharpClass()

Using CustomSymbolDictionary I am able to store the class created on the first 
call and then substitute it for every additional call to x from different 
scopes.  While this works to provide the same class instance to every scope, a 
new class is being created on every call and replaced with the original class.  
Is there a way to only create the class once.  The script will be user code so 
I have no prior knowledge of variable names and such.  Any ideas would be 
appreciated.

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

Reply via email to