Use a COM-server with python

dsavitsk dsavitsk at e-coli.net
Tue Nov 6 21:21:33 CET 2001


"Marc Gehling" <m.gehling at gmx.de> wrote in message
news:3BE83CFC.7060103 at gmx.de...
> Hello,
>
> I installed a comserver and i can use it with VB. I would like to use
> the server with python. I read some artikels and take a look at "python
> programming on win32".
>
> Can someone translate this vb into python ?
>
> Dim oRepo As MXLib.MXRepository
> Dim oNewFolder As MXFolder
> Set oRepo = New MXRepository
> oRepo.dbUserName = "rep"
> oRepo.dbPassword = "rep"
> oRepo.repUserName = "Administrator"
> oRepo.repPassword = "Administrator"
> oRepo.dbConnectString = "Inf ora8"
> oRepo.repositName = "data"
> oRepo.connect
> oRepo.CreateFolder "testfolder", "folderdescr", 0, "Administrators",
> oNewFolder
> oRepo.Disconnect
>
>

>>> import win32com.client
>>> oRepo = win32com.client.Dispatch("MXLib.MXRepository")
>>> oRepo.dbUserName() = "rep"
>>> oRepo.dbPassword() = "rep"
>>> oRepo.repUserName() = "Administrator"
>>> oRepo.repPassword() = "Administrator" # probably not the most secure
choice
>>> oRepo.dbConnectString() = "Inf ora8"
>>> oRepo.repositName() = "data"
>>> oRepo.connect()
>>> oRepo.CreateFolder("testfolder", "folderdescr", 0, "Administrators")
>>> # oNewFolder # not sure what this i as it was never set in the vb
example
>>> oRepo.Disconnect()

i have found that for com components written in vb sometimes () are
unnecessary when passing args.  i don't know why that is, though.  also, it
is likely that since "Disconnect" starts with "D" and not "d" "connect" will
be the same.  python is not forgiving in the same way as vb.

-d





More information about the Python-list mailing list