def _add_in_default_data(self, data): #need to return clone so we don't append more than once if self._template_data is not None: ret = copy.copy(data) else: ret = {} if not "config_" in ret: app_config = Config.get("app") app_config["www_url"] = AppUrl.get("web") app_config["api_url"] = AppUrl.get("api") app_config["assets_url"] = AppUrl.get("assets") app_config["admin_url"] = AppUrl.get("admin") ret['config_'] = { "app" : app_config, "www_url" : app_config["www_url"], "api_url" : app_config["api_url"], "assets_url" : app_config["assets_url"], "admin_url" : app_config["admin_url"], "app_json" : json.dumps(app_config) } if isinstance(self._user, Entity): ret["user_"] =self._user.to_dict(True) ret["user_json_"] =json.dumps(ret["user_"], default=self._json_helper) return ret
def get_map(self): """ Translates the routes dictionary configuration to a Map object """ routes_dict = copy.deepcopy(self._get_routes_dict()) ret = [] for host_type in routes_dict: routes_for_host = routes_dict[host_type] for subdomain in routes_for_host: subdomain_routes = routes_for_host.get(subdomain) host = AppUrl.get(subdomain, host_type, include_protocol=False) for route in subdomain_routes: path = route['route'] #cleanup route data that won't go to Rul del route['route'] rule = DocRule( path, host=host, **route ) ret.append(rule) return Map(ret,strict_slashes=False,host_matching=True)
def get_map(self): """ Translates the routes dictionary configuration to a Map object """ routes_dict = copy.deepcopy(self._get_routes_dict()) ret = [] for host_type in routes_dict: routes_for_host = routes_dict[host_type] for subdomain in routes_for_host: subdomain_routes = routes_for_host.get(subdomain) host = AppUrl.get(subdomain, host_type, include_protocol=False) for route in subdomain_routes: path = route['route'] #cleanup route data that won't go to Rul del route['route'] rule = DocRule(path, host=host, **route) ret.append(rule) return Map(ret, strict_slashes=False, host_matching=True)
def _add_in_default_data(self, data): #need to return clone so we don't append more than once if self._template_data is not None: ret = copy.copy(data) else: ret = {} if not "config_" in ret: app_config = Config.get("app") host_list = app_config['hosts'] #populate alias keys for host_type, host_config in host_list.items(): if 'host_alias' in host_config: alias_config = host_list[host_config['host_alias']] for k, v in alias_config.items(): if k not in host_config: host_config[k] = v host_type = self._host_type or "main" app_config["host_type"] = host_type app_config["www_url"] = AppUrl.get("web", host_type) app_config["api_url"] = AppUrl.get("api", host_type) app_config["assets_url"] = AppUrl.get("assets", host_type) app_config["admin_url"] = AppUrl.get("admin", host_type) ret['config_'] = { "app": app_config, "www_url": app_config["www_url"], "api_url": app_config["api_url"], "assets_url": app_config["assets_url"], "admin_url": app_config["admin_url"], "app_json": json.dumps(app_config) } if isinstance(self._user, Entity): ret["user_"] = self._user.to_dict(True, optional_keys=["email"]) ret["user_json_"] = json.dumps(ret["user_"], default=self._json_helper) return ret