[IronPython] CreateScriptSourceFrom ... database?
dinov at microsoft.com
Thu Mar 4 18:57:51 CET 2010
Replacing the PAL definitely isn't very obvious. First you need to subclass ScriptHost and override the PlatformAdaptationLayer property to return your subclass of the PAL. There's lots of file system related APIs on the PAL class that you'll want to override and redirect to the database. Then you create a ScriptRuntimeSetup object to create the script runtime - and on this you set the HostType property to the type of your ScriptHost. The DLR will then create an instance of you ScriptHost and get the PAL from it.
An example of this is the Silverlight host: http://ironpython.codeplex.com/SourceControl/changeset/view/64416#760498 has the ScriptHost and PAL and then the ScriptRuntimeSetup gets created over in DynamicEngine.cs: http://ironpython.codeplex.com/SourceControl/changeset/view/64416#944508
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mark Grice
Sent: Thursday, March 04, 2010 8:04 AM
To: users at lists.ironpython.com
Subject: Re: [IronPython] CreateScriptSourceFrom ... database?
Thanks for the reply. Actually, I did have an error in the string, and I fixed that. But the real problem seems to be with the "Import" statement. I put my common methods in a file that I then import into the various Python script files.
It makes sense that the script would error, since, as a string, it doesn't know how to handle the import.
It seems like the only way to go would be to replace the PlatformAdaptionLayer class as you suggest -- but to be honest, I don't even know where to begin with that.
Dino Viehland Wrote:
>Are the \r and \n getting escaped somehow? There should be no problem if the new lines are in the string the same as they would be in a file.
>Your solution generally sounds like the right and easy one to go with. If you wanted a more complicated solution you could replace the PlatformAdaptionLayer class >with your own which would read "files" from the database. That would enable things like "import foo" to work where the user could define a "foo" script in the database.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users