<div>Is IronPython.Modules.dll referenced by the host app?</div><br clear="all">~Jimmy<br>
<br><br><div class="gmail_quote">On Tue, Mar 15, 2011 at 12:22 PM, Slide <span dir="ltr"><<a href="mailto:slide.o.mix@gmail.com">slide.o.mix@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I am embedding IronPython in my app to allow some script capabilities.<br>
I have the following code:<br>
<br>
_content = content.Trim();<br>
<br>
string script = string.Format(@"<br>
import re<br>
<br>
def interp(string, variables):<br>
globals = globals()<br>
for item in re.findall(r'\$\(([^{{]*)\)', string):<br>
string = string.replace('$(%s)' % item,<br>
str(eval(item, globals, variables)))<br>
return string<br>
<br>
{0}<br>
", _content);<br>
<br>
try<br>
{<br>
_engine = Python.CreateEngine();<br>
List<string> searchPaths = new<br>
List<string>(_engine.GetSearchPaths());<br>
searchPaths.Add(<br>
<br>
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));<br>
<br>
_engine.SetSearchPaths(searchPaths);<br>
ScriptSource source =<br>
_engine.CreateScriptSourceFromString(script);<br>
<br>
_script = source.Compile();<br>
}<br>
catch(SyntaxErrorException ex)<br>
{<br>
ExceptionOperations eo =<br>
_engine.GetService<ExceptionOperations>();<br>
throw new ScriptedStringParseException(<br>
eo.FormatException(ex), -1);<br>
}<br>
<br>
Then later I call:<br>
<br>
_script.DefaultScope.SetVariable("context",<br>
GenerateParameters(context));<br>
return _script.Execute<string>();<br>
<br>
The problem I am running into is that _script.Execute is that I am<br>
getting an import exception on the "import re"<br>
<br>
re is a builtin module, so I am not sure why that is happening, does<br>
the IronPython.Modules.dll need to be in the DLLs directory? I don't<br>
remember having this issue previously.<br>
<font color="#888888"><br>
--<br>
slide-o-blog<br>
<a href="http://slide-o-blog.blogspot.com/" target="_blank">http://slide-o-blog.blogspot.com/</a><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</font></blockquote></div><br>