示例#1
0
 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
示例#2
0
文件: routes.py 项目: jordancode/phil
 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)
示例#3
0
文件: routes.py 项目: jordancode/phil
    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)
示例#4
0
    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
示例#5
0
    def track_url(self, event_or_list, next, request=None):

        if isinstance(event_or_list, list):
            event_or_list = sorted(event_or_list)
            event_or_list = ",".join(event_or_list)

        checksum = self._get_checksum(event_or_list)
        next = urllib.parse.quote(next)

        return AppUrl().get_current(
            request
        ) + "/r?checksum=" + checksum + "&event=" + event_or_list + "&next=" + next
示例#6
0
 def _get_cookie_domain(self):
     if self._request:
         server_name=AppUrl.get_current_cookie_domain(self._request)
     else:
         server_name="."+Config.get("app",["hosts", "main", "server_name"])
     return server_name