def update(updateMap=None, file=None, overwrite=True, baseurl=""): """Update configs from a dictionary or a config file. If overwrite is False then the update will not modify values already defined in the configs. """ if updateMap is None: updateMap = {} if file: if file not in autoreload.reloadFiles: autoreload.reloadFiles.append(file) updateMap = updateMap.copy() updateMap.update(dict_from_config_file(file)) # Load new conf into cherrypy.configs for section, valueMap in updateMap.iteritems(): # Handle shortcut syntax for "global" section # example: update({'server.socket_port': 80}) if not isinstance(valueMap, dict): valueMap = {section: valueMap} section = 'global' if baseurl and section.startswith("/"): if section == "/": section = baseurl else: section = httptools.urljoin(baseurl, section) bucket = configs.setdefault(section, {}) if overwrite: bucket.update(valueMap) else: for key, value in valueMap.iteritems(): bucket.setdefault(key, value)
def url(self, path, mount_point=None): """Return 'path', prefixed with mount_point. If mount_point is None, cherrypy.request.object_path will be used to find a mount point. """ if mount_point is None: mount_point = self.mount_point() if mount_point is None: return path from cherrypy.lib import httptools return httptools.urljoin(mount_point, path)
def getPage(self, url, headers=None, method="GET", body=None, protocol="HTTP/1.1"): """Open the url. Return status, headers, body.""" if self.mount_point: url = httptools.urljoin(self.mount_point, url) webtest.WebCase.getPage(self, url, headers, method, body, protocol)