[IronPython] Silverlight code need help (Repost)

Jimmy Schementi Jimmy.Schementi at microsoft.com
Mon Jan 11 19:08:48 PST 2010


> You must be getting sick of me :-P j/k

Na, I'm happy someone's asking this many questions about Silverlight. =)

> Ok I have a simple video player setup ultimately I would like to connect it
> to a Database. I am writing the database code but I am unsure how to $_GET 
> a value in IronPython. Although I will be honest and haven't done to much 
> research as of yet ;-) that will begin tonight.
>
> But if you have any advice on passing values to IronPython that would be 
> greatly appreciated

To make network calls from IronPython, you can use either System.Net.WebClient or System.Net.HttpWebRequest. Here's WebClient's basic usage:
 
from System import Uri
from System.Net import WebClient

def process_response(sender, event_args):
    print event_args.result

request = WebClient()
request.DownloadStringCompleted(process_response)
request.DownloadStringAsync(Uri("http://foo.com"))

WebClient also has an OpenReadAsync method which works the same way, but let's you get a Stream instead of a String. There is also HttpWebRequest, which is more powerful (doing post requests and such), but a bit more verbose. Doing some searching on the web will definitely yield a ton of C#/VB examples on how to do this, which should be straight-forward to convert to Python.

~js


More information about the Users mailing list