[pywin32-checkins] pywin32/isapi install.py,1.13,1.14
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Jason R. C. <ja...@us...> - 2008-12-16 02:59:31
|
Update of /cvsroot/pywin32/pywin32/isapi In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv13781 Modified Files: install.py Log Message: Fixed error in AssignScriptMaps (for 'end' and 'start') Further refactoring to support installing in root of web site (just use '/' as the Name). Note, remove/uninstall still will not work. Moved directory type definition into parameters and defaults to 'IIS_WebVirtualDir'. Index: install.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/isapi/install.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** install.py 14 Dec 2008 23:19:12 -0000 1.13 --- install.py 16 Dec 2008 02:59:24 -0000 1.14 *************** *** 61,64 **** --- 61,65 ---- Headers = _DEFAULT_HEADERS Path = None # defaults to WWW root. + Type = _IIS_WEBVIRTUALDIR AccessExecute = _DEFAULT_ACCESS_EXECUTE AccessRead = _DEFAULT_ACCESS_READ *************** *** 139,147 **** description (case-insensitive). ! >>> LocateWebServer('Default Web Site') # doctest: +SKIP or ! >>> LocateWebServer('1') #doctest: +SKIP """ assert len(description) >= 1, "Server name or comment is required" --- 140,148 ---- description (case-insensitive). ! >>> LocateWebServerPath('Default Web Site') # doctest: +SKIP or ! >>> LocateWebServerPath('1') #doctest: +SKIP """ assert len(description) >= 1, "Server name or comment is required" *************** *** 151,155 **** # Name is generally a number, but no need to assume that. site_attributes = [getattr(site, attr, "").lower().strip() ! for attr in ("Name", "ServerComment")] if description in site_attributes: return site.AdsPath --- 152,156 ---- # Name is generally a number, but no need to assume that. site_attributes = [getattr(site, attr, "").lower().strip() ! for attr in ("Name", "ServerComment")] if description in site_attributes: return site.AdsPath *************** *** 196,217 **** return server.adsPath ! def CreateDirectory(params, options): ! _CallHook(params, "PreInstall", options) ! if not params.Name: ! raise ConfigurationError("No Name param") ! slash = params.Name.rfind("/") if slash >= 0: ! parent = params.Name[:slash] ! name = params.Name[slash+1:] else: parent = "" ! name = params.Name ! webDir = GetObject(FindPath(options, params.Server, parent)) ! if parent: ! # Note that the directory won't be visible in the IIS UI ! # unless the directory exists on the filesystem. ! keyType = _IIS_WEBDIR ! else: ! keyType = _IIS_WEBVIRTUALDIR # We used to go to lengths to keep an existing virtual directory # in place. However, in some cases the existing directories got --- 197,236 ---- return server.adsPath ! def old_split_path(path): ! slash = path.rfind("/") if slash >= 0: ! parent = path[:slash] ! name = path[slash+1:] else: parent = "" ! name = path ! return parent, name ! ! def split_path(path): ! """ ! Get the parent path and basename ! >>> old_split_path('/') == split_path('/') ! True ! ! >>> old_split_path('') == split_path('') ! True ! ! >>> old_split_path('foo') == split_path('foo') ! True ! ! >>> old_split_path('/foo') == split_path('/foo') ! True ! ! >>> old_split_path('/foo/bar') == split_path('/foo/bar') ! True ! ! >>> old_split_path('foo/bar') == split_path('foo/bar') ! False ! """ ! ! if not path.startswith('/'): path = '/' + path ! return tuple(path.rsplit('/', 1)) ! ! def ReallyCreateDirectory(iis_dir, name, params): # We used to go to lengths to keep an existing virtual directory # in place. However, in some cases the existing directories got *************** *** 222,240 **** # Also seen the Class change to a generic IISObject - so nuke # *any* existing object, regardless of Class ! existing = GetObject(FindPath(options, params.Server, params.Name)) ! webDir.Delete(existing.Class, existing.Name) ! log(2, "Deleted old directory '%s'" % (params.Name,)) except pythoncom.com_error: pass ! newDir = webDir.Create(keyType, name) ! log(2, "Creating new directory '%s'..." % (params.Name,)) friendly = params.Description or params.Name newDir.AppFriendlyName = friendly try: path = params.Path or webDir.Path newDir.Path = path except AttributeError: pass newDir.AppCreate2(params.AppProtection) --- 241,262 ---- # Also seen the Class change to a generic IISObject - so nuke # *any* existing object, regardless of Class ! existing = iis_dir.Delete('', name) ! log(2, "Deleted old directory '%s'" % (name,)) except pythoncom.com_error: pass ! newDir = iis_dir.Create(params.Type, name) ! log(2, "Creating new directory '%s' in %s..." % (name,iis_dir.Name)) friendly = params.Description or params.Name newDir.AppFriendlyName = friendly + + # Note that the new directory won't be visible in the IIS UI + # unless the directory exists on the filesystem. try: path = params.Path or webDir.Path newDir.Path = path except AttributeError: + # If params.Type is IIS_WEBDIRECTORY, an exception is thrown pass newDir.AppCreate2(params.AppProtection) *************** *** 252,261 **** newDir.DefaultDoc = params.DefaultDoc newDir.SetInfo() ! AssignScriptMaps(params.ScriptMaps, newDir, params.ScriptMapUpdate) ! _CallHook(params, "PostInstall", options, newDir) log(1, "Configured Virtual Directory: %s" % (params.Name,)) ! return newDir def AssignScriptMaps(script_maps, target, update='replace'): --- 274,297 ---- newDir.DefaultDoc = params.DefaultDoc newDir.SetInfo() + return newDir ! ! def CreateDirectory(params, options): ! _CallHook(params, "PreInstall", options) ! if not params.Name: ! raise ConfigurationError("No Name param") ! parent, name = split_path(params.Name) ! webDir = GetObject(FindPath(options, params.Server, parent)) ! ! # if '/' or '' was passed, we must be installing to the root. ! # In this case, name is blank. ! if name: ! webDir = ReallyCreateDirectory(webDir, name, params) ! ! AssignScriptMaps(params.ScriptMaps, webDir, params.ScriptMapUpdate) ! _CallHook(params, "PostInstall", options, webDir) log(1, "Configured Virtual Directory: %s" % (params.Name,)) ! return webDir def AssignScriptMaps(script_maps, target, update='replace'): *************** *** 280,284 **** def get_unique_items(sequence, reference): "Return items in sequence that can't be found in reference." ! return [item for item in sequence if item not in reference] def _AssignScriptMapsReplace(target, script_maps): --- 316,320 ---- def get_unique_items(sequence, reference): "Return items in sequence that can't be found in reference." ! return tuple([item for item in sequence if item not in reference]) def _AssignScriptMapsReplace(target, script_maps): |