예제 #1
0
 def init_options(self, options):
     logging.basicConfig(level=logging.CRITICAL)
     default_options = {
         "application": {
             "address": "127.0.0.1",
             "port": 8080,
             "system": {
                 "log": None
             }
         },
         "urls": {},
         "views": {
             "templates_path": [],
             "templates_extensions":
             ["compressinja.html.HtmlCompressor", "jinja2.ext.i18n"],
             "static_path": [],
             "static_not_compile": [],
             "static_build":
             True,
             'session_type':
             "cookie",
             "session_auto":
             True,
             'session_cookie_expires':
             True,
             'session_encrypt_key':
             'sldk24j0jf09w0jfg24',
             'session_validate_key':
             ';l[pfghopkqeq1234,fs'
         },
         "events": {}
     }
     self.options = Dict.merge(default_options, options)
예제 #2
0
	def init_options(self, options):
		logging.basicConfig(level=logging.CRITICAL)
		default_options = {
			"application": {
				"address": "127.0.0.1",
				"port": 8080,
			    "system": {
				    "log": None
			    }
			},
			"urls": {},
			"views": {
				"templates_path": [],
				"templates_extensions": ["compressinja.html.HtmlCompressor", "jinja2.ext.i18n"],
				"static_path": [],
				"static_not_compile": [],
				"static_build": True,
				'session_type': "cookie",
				"session_auto": True,
				'session_cookie_expires': True,
				'session_encrypt_key':'sldk24j0jf09w0jfg24',
				'session_validate_key':';l[pfghopkqeq1234,fs'
			},
			"events": {}
		}
		self.options = Dict.merge(default_options, options)
예제 #3
0
파일: auth.py 프로젝트: travofoz/kiss.py
 def __init__(self, opts):
     self.options = {
         "common": {
             "base_uri": "http://localhost:8080/auth/",
             "success_uri": "success/",
             "error_uri": "error/"
         },
         "google": {
             "authorization_uri":
             "https://accounts.google.com/o/oauth2/auth",
             "scope":
             "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
             "get_token_uri": "https://accounts.google.com/o/oauth2/token",
             "redirect_uri": "google/callback",
             "target_uri": "https://www.googleapis.com/oauth2/v1/userinfo",
             "backend": GoogleAuthBackend()
         },
         "vk": {
             "authorization_uri": "http://api.vk.com/oauth/authorize",
             "scope": "",
             "get_token_uri": "https://api.vk.com/oauth/token",
             "redirect_uri": "vk/callback",
             "target_uri": "https://api.vk.com/method/users.get",
             "backend": VkAuthBackend()
         },
         "facebook": {
             "authorization_uri": "https://www.facebook.com/dialog/oauth",
             "scope": "email",
             "get_token_uri":
             "https://graph.facebook.com/oauth/access_token",
             "redirect_uri": "facebook/callback",
             "target_uri": "https://graph.facebook.com/me",
             "backend": FacebookAuthBackend()
         },
         "yandex": {
             "authorization_uri": "https://oauth.yandex.ru/authorize",
             "scope": "",
             "get_token_uri": "https://oauth.yandex.ru/token",
             "redirect_uri": "yandex/callback",
             "target_uri": "https://login.yandex.ru/info",
             "backend": YandexAuthBackend()
         }
     }
     self.options = Dict.merge(self.options, opts)
     base_uri = self.options["common"]["base_uri"]
     self.options["common"]["success_uri"] = urljoin(
         base_uri, self.options["common"]["success_uri"])
     self.options["common"]["error_uri"] = urljoin(
         base_uri, self.options["common"]["error_uri"])
     for backend, params in self.options.items():
         if "redirect_uri" in params:
             params["redirect_uri"] = urljoin(base_uri,
                                              params["redirect_uri"])
예제 #4
0
파일: auth.py 프로젝트: stanfeldman/samples
	def __new__(cls, opts):
		AuthController.options = Dict.merge(AuthController.options, opts)
		base_uri = AuthController.options["common"]["base_uri"]
		AuthController.options["common"]["success_uri"] = urljoin(base_uri, AuthController.options["common"]["success_uri"])
		AuthController.options["common"]["error_uri"] = urljoin(base_uri, AuthController.options["common"]["error_uri"])
		for backend, params in AuthController.options.items():
			if "redirect_uri" in params:
				params["redirect_uri"] = urljoin(base_uri, params["redirect_uri"])
		return {
			Regex.string_url_regex("backend"): {
				"": StartAuthController,
				"callback": EndAuthController,
			}
		}
예제 #5
0
파일: router.py 프로젝트: Danisan/kiss.py
	def add_urls(self, urls, merge=True):
		urls = Dict.flat_dict(urls)
		new_urls = []
		for k, v in urls.iteritems():
			if k[len(k)-2] == "/":
				k = k[:len(k)-2] + k[len(k)-1]
			k = re.compile(k)
			if inspect.isclass(v):
				new_urls.append((k, v()))
			else:
				new_urls.append((k,v))
		if merge:
			self.options["urls"] = self.options["urls"] + new_urls
		else:
			self.options["urls"] = new_urls
예제 #6
0
파일: router.py 프로젝트: travofoz/kiss.py
 def add_urls(self, urls, merge=True):
     urls = Dict.flat_dict(urls)
     new_urls = []
     for k, v in urls.iteritems():
         if k[len(k) - 2] == "/":
             k = k[:len(k) - 2] + k[len(k) - 1]
         k = re.compile(k)
         if inspect.isclass(v):
             new_urls.append((k, v()))
         else:
             new_urls.append((k, v))
     if merge:
         self.options["urls"] = self.options["urls"] + new_urls
     else:
         self.options["urls"] = new_urls
예제 #7
0
파일: auth.py 프로젝트: Danisan/kiss.py
	def __init__(self, opts):
		self.options = {
			"common": {
				"base_uri": "http://localhost:8080/auth/",
				"success_uri": "success/",
				"error_uri": "error/"
			},
			"google": {
				"authorization_uri": "https://accounts.google.com/o/oauth2/auth",
				"scope": "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email",
				"get_token_uri": "https://accounts.google.com/o/oauth2/token",
				"redirect_uri": "google/callback",
				"target_uri": "https://www.googleapis.com/oauth2/v1/userinfo",
				"backend": GoogleAuthBackend()
			},
			"vk": {
				"authorization_uri": "http://api.vk.com/oauth/authorize",
				"scope": "",
				"get_token_uri": "https://api.vk.com/oauth/token",
				"redirect_uri": "vk/callback",
				"target_uri": "https://api.vk.com/method/users.get",
				"backend": VkAuthBackend()
			},
			"facebook": {
				"authorization_uri": "https://www.facebook.com/dialog/oauth",
				"scope": "email",
				"get_token_uri": "https://graph.facebook.com/oauth/access_token",
				"redirect_uri": "facebook/callback",
				"target_uri": "https://graph.facebook.com/me",
				"backend": FacebookAuthBackend()
			},
			"yandex": {
				"authorization_uri": "https://oauth.yandex.ru/authorize",
				"scope": "",
				"get_token_uri": "https://oauth.yandex.ru/token",
				"redirect_uri": "yandex/callback",
				"target_uri": "https://login.yandex.ru/info",
				"backend": YandexAuthBackend()
			}
		}
		self.options = Dict.merge(self.options, opts)
		base_uri = self.options["common"]["base_uri"]
		self.options["common"]["success_uri"] = urljoin(base_uri, self.options["common"]["success_uri"])
		self.options["common"]["error_uri"] = urljoin(base_uri, self.options["common"]["error_uri"])
		for backend, params in self.options.items():
			if "redirect_uri" in params:
				params["redirect_uri"] = urljoin(base_uri, params["redirect_uri"])
예제 #8
0
	def init_controllers_mapping(self):
		controllers_mapping = Dict.flat_dict(self.settings["controllers"], start_char="", end_char="")
		new_controllers_mapping = []
		for k, v in controllers_mapping.iteritems():
			if k[len(k)-2] == "/":
				k = k[:len(k)-2] + k[len(k)-1]
			if k[len(k)-1] == '/':
				k = k.rstrip('/')
			key = re.compile(k)
			if inspect.isclass(v):
				new_controllers_mapping.append((key, v()))
			elif isinstance(v, list):
				controllers = []
				for controller in v:
					if inspect.isclass(controller):
						controllers.append(controller())
					else:
						controllers.append(controller)
				new_controllers_mapping.append((key, controllers))
			else:
				new_controllers_mapping.append((key, v))
		self.settings["controllers"] = new_controllers_mapping
예제 #9
0
def start(options):
	opts = Dict.merge(core_options, options)
	app = Application(options)
	app.start()