Changeset 20036 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 26, 2009 1:21:41 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/vboxapi.py
r19902 r20036 106 106 #win32com.client.gencache.EnsureDispatch('VirtualBox.VirtualBox') 107 107 108 def getSessionObject(self ):108 def getSessionObject(self, vbox): 109 109 import win32com 110 110 from win32com.client import Dispatch … … 145 145 import xpcom.components 146 146 147 def getSessionObject(self ):147 def getSessionObject(self, vbox): 148 148 import xpcom.components 149 149 return xpcom.components.classes["@virtualbox.org/Session;1"].createInstance() … … 177 177 import VirtualBox_services 178 178 import VirtualBox_wrappers 179 from VirtualBox_wrappers import IWebsessionManager 180 from VirtualBox_wrappers import g_port 181 from VirtualBox_wrappers import g_reflectionInfo 182 self.wsmgr = IWebsessionManager() 183 self.port = g_port 184 self.constants = g_reflectionInfo 185 self.user = "" 186 self.password = "" 187 188 def getSessionObject(self): 189 return self.wsmgr.getSessionObject() 179 from VirtualBox_wrappers import IWebsessionManager2 180 if params is not None: 181 self.user = params.get("user", "") 182 self.password = params.get("password", "") 183 self.url = params.get("url", "") 184 else: 185 self.user = "" 186 self.password = "" 187 self.url = None 188 self.wsmgr = IWebsessionManager2(self.url) 189 190 def getSessionObject(self, vbox): 191 return self.wsmgr.getSessionObject(vbox) 190 192 191 193 def getVirtualBox(self): … … 193 195 194 196 def getConstants(self): 195 from VirtualBox_wrappers import g_reflectionInfo 196 return g_reflectionInfo 197 return None 197 198 198 199 def getType(self): … … 216 217 217 218 def getSessionObject(self, vbox): 218 return self.mgr.platform.getSessionObject( )219 return self.mgr.platform.getSessionObject(vbox) 219 220 220 221 class VirtualBoxManager: -
trunk/src/VBox/Main/webservice/Makefile.kmk
r19853 r20036 326 326 # 327 327 VBOXWEB_GLUE_PYTHON = $(VBOX_PATH_SDK)/bindings/webservice/python/lib/VirtualBox_wrappers.py 328 VBOXWEB_WS_PYTHON = $(VBOX_PATH_SDK)/bindings/webservice/python/lib/VirtualBox_service .py328 VBOXWEB_WS_PYTHON = $(VBOX_PATH_SDK)/bindings/webservice/python/lib/VirtualBox_services.py 329 329 VBOXWEB_WS_PERL = $(VBOX_PATH_SDK)/bindings/webservice/perl/lib/vboxService.pm 330 330 VBOXWEB_SAMPLES_AXIS_DIR = $(VBOX_PATH_SDK)/bindings/webservice/java/axis/samples -
trunk/src/VBox/Main/webservice/websrv-python.xsl
r19320 r20036 72 72 </xsl:call-template> 73 73 <xsl:text>(</xsl:text> 74 <xsl:text>self.mgr,</xsl:text> 74 75 <xsl:value-of select="$value"/> 75 76 <xsl:if test="$safearray='yes'"> … … 89 90 req=<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>RequestMsg() 90 91 req._this=self.handle 91 val= g_port.<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)92 val=self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req) 92 93 <xsl:text>return </xsl:text> 93 94 <xsl:call-template name="emitOutParam"> … … 113 114 else: 114 115 req._<xsl:value-of select="$attrname"/> = value.handle 115 g_port.<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req)116 self.mgr.getPort().<xsl:value-of select="$ifname"/>_<xsl:value-of select="$fname"/>(req) 116 117 </xsl:template> 117 118 … … 120 121 <xsl:variable name="ename"><xsl:value-of select="@type" /></xsl:variable> 121 122 class <xsl:value-of select="$cname"/>: 122 def __init__(self, array):123 def __init__(self, mgr, array): 123 124 self.array = array 125 self.mgr = mgr 124 126 125 127 def __next(self): … … 133 135 134 136 def __getitem__(self, index): 135 return <xsl:value-of select="$ename"/>(self. array._array[index])137 return <xsl:value-of select="$ename"/>(self.mgr, self.array._array[index]) 136 138 137 139 </xsl:template> … … 140 142 <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable> 141 143 class <xsl:value-of select="$ifname"/>: 142 def __init__(self, handle = None,isarray = False): 144 def __init__(self, mgr, handle, isarray = False): 145 self.mgr = mgr 146 if handle is None or handle == "": 147 raise Exception("bad handle: "+str(handle)) 143 148 self.handle = handle 144 149 self.isarray = isarray 145 150 <!-- 146 151 This doesn't work now 147 g_manMgr.register(handle)152 mgr.register(handle) 148 153 149 154 def __del__(self): 150 g_manMgr.unregister(self.handle)155 mgr.unregister(self.handle) 151 156 --> 152 157 def releaseRemote(self): … … 154 159 req=IManagedObjectRef_releaseRequestMsg() 155 160 req._this=handle 156 g_port.IManagedObjectRef_release(req)161 self.mgr.getPort().IManagedObjectRef_release(req) 157 162 except: 158 163 pass … … 175 180 def __getitem__(self, index): 176 181 if self.isarray: 177 return <xsl:value-of select="$ifname" />(self. handle[index])182 return <xsl:value-of select="$ifname" />(self.mgr, self.handle[index]) 178 183 raise TypeError, "iteration over non-sequence" 179 184 … … 267 272 <xsl:variable name="ifname"><xsl:value-of select="@name" /></xsl:variable> 268 273 class <xsl:value-of select="$ifname"/>: 269 def __init__(self, handle):<xsl:for-each select="attribute"> 274 def __init__(self, mgr, handle):<xsl:for-each select="attribute"> 275 self.mgr = mgr 270 276 self.<xsl:value-of select="@name"/> = handle._<xsl:value-of select="@name"/> 271 277 </xsl:for-each> … … 287 293 req._<xsl:value-of select="@name" />=_arg_<xsl:value-of select="@name" /> 288 294 </xsl:for-each> 289 val= g_port.<xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>(req)295 val=self.mgr.getPort().<xsl:value-of select="../@name"/>_<xsl:value-of select="@name"/>(req) 290 296 <!-- return needs to be the first one --> 291 297 return <xsl:for-each select="param[@dir='return']"> … … 339 345 <xsl:template name="enum"> 340 346 class <xsl:value-of select="@name"/>: 341 def __init__(self,handle): 347 def __init__(self,mgr,handle): 348 self.mgr=mgr 342 349 if isinstance(handle,basestring): 343 350 self.handle=<xsl:value-of select="@name"/>._ValueMap[handle] … … 395 402 from VirtualBox_services import * 396 403 397 g_port = vboxServiceLocator().getvboxPortType()398 399 404 class ManagedManager: 400 405 def __init__(self): … … 419 424 req=IManagedObjectRef_releaseRequestMsg() 420 425 req._this=handle 421 g_port.IManagedObjectRef_release(req)426 self.mgr.getPort().IManagedObjectRef_release(req) 422 427 except: 423 428 pass … … 426 431 else: 427 432 self.map[handle] = c 428 429 g_manMgr = ManagedManager() 430 433 431 434 class String: 432 def __init__(self, handle = None, isarray = False):435 def __init__(self, mgr, handle, isarray = False): 433 436 self.handle = handle 434 437 self.isarray = isarray … … 477 480 478 481 class UUID: 479 def __init__(self, handle = None, isarray = False):482 def __init__(self, mgr, handle, isarray = False): 480 483 self.handle = handle 481 484 self.isarray = isarray … … 523 526 524 527 class Boolean: 525 def __init__(self, handle = None, isarray = False):528 def __init__(self, mgr, handle, isarray = False): 526 529 self.handle = handle 527 530 self.isarray = isarray … … 545 548 546 549 class UnsignedInt: 547 def __init__(self, handle = None, isarray = False):550 def __init__(self, mgr, handle, isarray = False): 548 551 self.handle = handle 549 552 self.isarray = isarray … … 577 580 578 581 class Int: 579 def __init__(self, handle = None, isarray = False):582 def __init__(self, mgr, handle, isarray = False): 580 583 self.handle = handle 581 584 self.isarray = isarray … … 608 611 609 612 class UnsignedShort: 610 def __init__(self, handle = None, isarray = False):613 def __init__(self, mgr, handle, isarray = False): 611 614 self.handle = handle 612 615 self.isarray = isarray … … 619 622 620 623 class Short: 621 def __init__(self, handle = None, isarray = False):624 def __init__(self, mgr, handle, isarray = False): 622 625 self.handle = handle 623 626 … … 629 632 630 633 class UnsignedLong: 631 def __init__(self, handle = None, isarray = False):634 def __init__(self, mgr, handle, isarray = False): 632 635 self.handle = handle 633 636 … … 639 642 640 643 class Long: 641 def __init__(self, handle = None, isarray = False):644 def __init__(self, mgr, handle, isarray = False): 642 645 self.handle = handle 643 646 … … 649 652 650 653 class Double: 651 def __init__(self, handle = None, isarray = False):654 def __init__(self, mgr, handle, isarray = False): 652 655 self.handle = handle 653 656 … … 659 662 660 663 class Float: 661 def __init__(self, handle = None, isarray = False):662 self.handle = handle 663 664 def __init__(self, mgr, handle, isarray = False): 665 self.handle = handle 666 664 667 def __str__(self): 665 668 return str(self.handle) … … 670 673 671 674 class IUnknown: 672 def __init__(self, handle = None, isarray = False): 673 self.handle = handle 675 def __init__(self, mgr, handle, isarray = False): 676 self.handle = handle 677 self.mgr = mgr 674 678 self.isarray = isarray 675 679 … … 691 695 def __getitem__(self, index): 692 696 if self.isarray: 693 return IUnknown(self. handle[index])697 return IUnknown(self.mgr, self.handle[index]) 694 698 raise TypeError, "iteration over non-sequence" 695 699 … … 711 715 </xsl:for-each> 712 716 713 class VirtualBoxReflectionInfo: 714 def __init__(self): 715 self.map = {} 716 717 def add(self,name,ref): 718 self.map[name] = ref 719 720 def __getattr__(self,name): 721 ref = self.map.get(name,None) 722 if ref == None: 723 return self.__dict__[name] 724 return ref 725 726 g_reflectionInfo = VirtualBoxReflectionInfo() 727 <xsl:for-each select="//enum"> 728 <xsl:variable name="ename"> 729 <xsl:value-of select="@name"/> 730 </xsl:variable> 731 <xsl:value-of select="concat('g_reflectionInfo.add("',$ename,'",',$ename,') ')"/> 732 </xsl:for-each> 717 class IWebsessionManager2(IWebsessionManager): 718 def __init__(self, url): 719 self.url = url 720 self.port = None 721 self.handle = None 722 self.mgr = self 723 724 def getPort(self): 725 if self.port is None: 726 self.port = vboxServiceLocator().getvboxPortType(self.url) 727 return self.port 733 728 734 729 </xsl:template>
Note:
See TracChangeset
for help on using the changeset viewer.