[vbox-dev] Accessing the enums from python

Narf narf at mundo-r.com
Tue May 26 00:38:47 PDT 2009


Thank you. I'll use xpcom.components.interfaces for now (I'm using
xpcom in vboxgtk-svn anyway) and change it when vboxapi.py is
released.

Regards,
Fran

On Mon, May 25, 2009 at 9:39 PM, Nikolay Igotti <Nikolay.Igotti at sun.com> wrote:
>   Hi Narf,
>
> Yes, it is possible, and there are two approaches to that:
> -  platform (COM/XPCOM/webservices) specific (not recommended for XPCOM, not
> available for MSCOM, OK for webservices)
> - platform neutral (implemented in recent SVN tree) - (recommended)
>
> First approach it to use component technology's specific mechanism to access
> constants data available in typelib.
> To do that, for XPCOM xpcom.components.interfaces can be used, such as
> xpcom.components.interfaces.MachineState.Running.
> For webservices, one can use g_reflectionInfo in VirtualBox_wrappers
> (g_reflectionInfo.MachineState.Running).
>  For MS COM there's no reliable mechanism to do that
> (win32com.client.constants
> doesn't work entirely expected way).
>
> Second approach, is to use pregenerated constants file, and rely on
> universal wrapper vboxapi.py to access constants, like this:
>  virtualBoxManager = VirtualBoxManager(None, None)
>  g_virtualBoxManager.constants.MachineState_Running
>
> Note underscore in constant's name.
>
> Class VirtualBoxManager hides platform-specific implementation details, and
> allow to write the same Python code for Windows, Linux and webservices.
>
> Will work on improving of Python sections in SDK documentation .
>
> Thanks,
>   Nikolay
>
>
> Narf wrote:
>>
>> Hi,
>>
>> Is it possible to access the enums (MachineState, HardDiskType, etc)
>> from python? I'm programming a python interface to virtualbox and I
>> feel stupid hardcoding the numbers. And the python section in the sdk
>> documentation is not... erm... very helpful :)
>>
>> Thanks,
>> Narf
>>
>> _______________________________________________
>> vbox-dev mailing list
>> vbox-dev at virtualbox.org
>> http://vbox.innotek.de/mailman/listinfo/vbox-dev
>>
>
>




More information about the vbox-dev mailing list