help with a com object

Scott Hathaway slhath at home.com.nospam
Wed Aug 30 09:29:08 EDT 2000


Hello All,

I am trying to create a COM object in python to use with PHP 4.  I have
listed the entire code below.  All I want it to do is have one method that
is passed a directory to scan and a flag that tells to return subfolders or
files.  From PHP, I can instantiate the COM object without errors, but it
fails with an exception on the call to GetListing.

class PythonDir:
 _public_methods_ = [ 'GetListing' ]
 _reg_progid_ = "PythonDir.Utils"
 _reg_clsid_ = "{95CBD1B0-7E6F-11D4-AB71-0000929181BF}"

 def GetListing(str(thePath), str(theType)):
  import os
  myFiles = os.listdir(thePath)
  for x in myFiles :
   if theType == "f":
    if os.path.isfile(thePath + x):
     print x + '|',
   else:
    if os.path.isdir(thePath + x):
     print x + '|',

if __name__=='__main__':
 print "Registering COM Server..."
 import win32com.server.register
 win32com.server.register.UseCommandLine(PythonDir)

Here is the php code:

$pyCOM = new COM("PythonDir.Utils");
$pyCOM->GetListing("c:\\", "f");

Please help!

Thanks,
Scott





More information about the Python-list mailing list