Re: [IronPython] custom ConfigurationSection in IronPython

2006-09-01 Thread Jason Ferrara

On Aug 31, 2006, at 4:00 PM, Dino Viehland wrote:

 The Item property is the default indexer, so you should be able to  
 access it using foo[index].

 As for your other question - Martin looked into this but I didn't  
 see a response from him...  The problem seems to be that we don't  
 define a parameterless constructor that the configuration section  
 can call.  The reason for that is that our objects actually need to  
 receive a DynamicType object which represents the class - without  
 this we wouldn't be able to know your type was MySettings.   
 Unfortunately I think this might make it impossible for you to  
 define this class in IronPython.  You could define a stub in C#  
 that calls into your Python using the engine APIs but that might be  
 more work than it's worth.


If I wanted to write a stub in C#, how do I get access to a  
PythonEngine that represents the python environment that called the  
C# code? Just calling IronPython.Hosting.PythonEngine() seems to get  
me a new environment.
___
users mailing list
users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] custom ConfigurationSection in IronPython

2006-08-31 Thread Jason Ferrara
I have another related question.  The Item property of  
System.Configuration.ConfigurationElement (base class for  
ConfigurationSection) doesn't seem to be accessible from IronPython.   
Is this because its overloaded by parameter type? Is there a way to  
access it from IronPython?

Thanks

- Jason

On Aug 30, 2006, at 2:33 PM, Jason Ferrara wrote:

 I want to write a custon ConfigurationSection in IronPython. So I  
 try...

 class MySettings(System.Configuration.ConfigurationSection):
   # custom configuration stuff here

 c = System.Configuration.ConfigurationManager.OpenExeConfiguration( \
  System.Configuration.ConfigurationUserLevel.PerUserRoaming)
 c.Sections.Add(mysettings,MySettings())

 and get...

File , line 0, in Add##32
File System.Configuration, line unknown, in Add
File System.Configuration, line unknown, in AddConfigurationSection
File System.Configuration, line unknown, in
 GetConstructorWithReflectionPermis
 sion
 SystemError: Unable to load type
 'IronPython.NewTypes.System.Configuration.ConfigurationSection_2,
 snippets1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
 because it is not public.

 This happened even when the python code is compiled into an assembly.

 Is there a way to make this work?

 I saw a post that mentioned an experimental static type compiler.
 Would I need to use that, and if so how?

 Thanks.

 - Jason
 ___
 users mailing list
 users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

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


Re: [IronPython] custom ConfigurationSection in IronPython

2006-08-31 Thread Dino Viehland
The Item property is the default indexer, so you should be able to access it 
using foo[index].

As for your other question - Martin looked into this but I didn't see a 
response from him...  The problem seems to be that we don't define a 
parameterless constructor that the configuration section can call.  The reason 
for that is that our objects actually need to receive a DynamicType object 
which represents the class - without this we wouldn't be able to know your type 
was MySettings.  Unfortunately I think this might make it impossible for you to 
define this class in IronPython.  You could define a stub in C# that calls into 
your Python using the engine APIs but that might be more work than it's worth.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Ferrara
Sent: Thursday, August 31, 2006 12:56 PM
To: Discussion of IronPython
Subject: Re: [IronPython] custom ConfigurationSection in IronPython

I have another related question.  The Item property of 
System.Configuration.ConfigurationElement (base class for
ConfigurationSection) doesn't seem to be accessible from IronPython.
Is this because its overloaded by parameter type? Is there a way to access it 
from IronPython?

Thanks

- Jason

On Aug 30, 2006, at 2:33 PM, Jason Ferrara wrote:

 I want to write a custon ConfigurationSection in IronPython. So I
 try...

 class MySettings(System.Configuration.ConfigurationSection):
   # custom configuration stuff here

 c = System.Configuration.ConfigurationManager.OpenExeConfiguration( \
  System.Configuration.ConfigurationUserLevel.PerUserRoaming)
 c.Sections.Add(mysettings,MySettings())

 and get...

File , line 0, in Add##32
File System.Configuration, line unknown, in Add
File System.Configuration, line unknown, in AddConfigurationSection
File System.Configuration, line unknown, in
 GetConstructorWithReflectionPermis
 sion
 SystemError: Unable to load type
 'IronPython.NewTypes.System.Configuration.ConfigurationSection_2,
 snippets1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
 because it is not public.

 This happened even when the python code is compiled into an assembly.

 Is there a way to make this work?

 I saw a post that mentioned an experimental static type compiler.
 Would I need to use that, and if so how?

 Thanks.

 - Jason
 ___
 users mailing list
 users@lists.ironpython.com
 http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

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


Re: [IronPython] custom ConfigurationSection in IronPython

2006-08-31 Thread Jason Ferrara

On Aug 31, 2006, at 4:00 PM, Dino Viehland wrote:

 The Item property is the default indexer, so you should be able to  
 access it using foo[index].

Thats what I thought, but it doesn't work. And if I do dir() on  
ConfigurationElement I don't see a __getitem__ or __setitem__, though  
with other .NET classes that have the Item property I do.


 As for your other question - Martin looked into this but I didn't  
 see a response from him...  The problem seems to be that we don't  
 define a parameterless constructor that the configuration section  
 can call.  The reason for that is that our objects actually need to  
 receive a DynamicType object which represents the class - without  
 this we wouldn't be able to know your type was MySettings.   
 Unfortunately I think this might make it impossible for you to  
 define this class in IronPython.  You could define a stub in C#  
 that calls into your Python using the engine APIs but that might be  
 more work than it's worth.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:users- 
 [EMAIL PROTECTED] On Behalf Of Jason Ferrara
 Sent: Thursday, August 31, 2006 12:56 PM
 To: Discussion of IronPython
 Subject: Re: [IronPython] custom ConfigurationSection in IronPython

 I have another related question.  The Item property of  
 System.Configuration.ConfigurationElement (base class for
 ConfigurationSection) doesn't seem to be accessible from IronPython.
 Is this because its overloaded by parameter type? Is there a way to  
 access it from IronPython?

 Thanks

 - Jason


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


Re: [IronPython] custom ConfigurationSection in IronPython

2006-08-31 Thread Dino Viehland
Ahh, you're right - currently it looks like we won't ever get non-public 
indexers (this one is family or assembly, which is protected internal in C# 
speak).  This is a bug, I've opened CodePlex bug #2766 for this 
(http://www.codeplex.com/WorkItem/List.aspx?ProjectName=IronPython).

A simple workaround would be to write a class in C# that derives from this and 
exposes these publicly, and then use that class from IronPython.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Ferrara
Sent: Thursday, August 31, 2006 1:14 PM
To: Discussion of IronPython
Subject: Re: [IronPython] custom ConfigurationSection in IronPython


On Aug 31, 2006, at 4:00 PM, Dino Viehland wrote:

 The Item property is the default indexer, so you should be able to
 access it using foo[index].

Thats what I thought, but it doesn't work. And if I do dir() on 
ConfigurationElement I don't see a __getitem__ or __setitem__, though with 
other .NET classes that have the Item property I do.


 As for your other question - Martin looked into this but I didn't see
 a response from him...  The problem seems to be that we don't define a
 parameterless constructor that the configuration section can call.
 The reason for that is that our objects actually need to receive a
 DynamicType object which represents the class - without this we
 wouldn't be able to know your type was MySettings.
 Unfortunately I think this might make it impossible for you to define
 this class in IronPython.  You could define a stub in C# that calls
 into your Python using the engine APIs but that might be more work
 than it's worth.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:users-
 [EMAIL PROTECTED] On Behalf Of Jason Ferrara
 Sent: Thursday, August 31, 2006 12:56 PM
 To: Discussion of IronPython
 Subject: Re: [IronPython] custom ConfigurationSection in IronPython

 I have another related question.  The Item property of
 System.Configuration.ConfigurationElement (base class for
 ConfigurationSection) doesn't seem to be accessible from IronPython.
 Is this because its overloaded by parameter type? Is there a way to
 access it from IronPython?

 Thanks

 - Jason


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