Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _load_params_form_urlencoded(self, data):
rv = sdict()
for key, values in parse_qs(
data.decode(), keep_blank_values=True
).items():
if len(values) == 1:
rv[key] = values[0]
continue
rv[key] = values
return rv, sdict()
def __init_extension(self, ext):
if ext.namespace is None:
ext.namespace = ext.__name__
if self._extensions_env[ext.namespace] is None:
self._extensions_env[ext.namespace] = sdict()
return self._extensions_env[ext.namespace], self.config[ext.namespace]
#: init routing
self._router_http = HTTPRouter(self)
self._router_ws = WebsocketRouter(self)
self._asgi_handlers = {
'http': HTTPHandler(self),
'lifespan': LifeSpanHandler(self),
'websocket': WSHandler(self)
}
self.error_handlers = {}
self.template_default_extension = '.html'
#: init logger
self._logger = None
self.logger_name = self.import_name
#: init extensions
self.ext = sdict()
self._extensions_env = sdict()
self._extensions_listeners = {key: [] for key in Extension._signals_}
#: init templater
self.templater = Templater(
path=self.template_path,
encoding=self.config.templates_encoding,
escape=self.config.templates_escape,
prettify=self.config.templates_prettify,
reload=self.config.templates_auto_reload
)
#: store app in current
current.app = self
def _load_params_missing(self, data):
return sdict(), sdict()
new_reference = {func.__name__: {'method': func}}
field = self.params.get('field')
if field:
new_reference[func.__name__]['field'] = field
cast = self.params.get('cast')
if cast:
new_reference[func.__name__]['cast'] = cast
self.reference = [new_reference]
return self
@property
def refobj(self):
return {}
class ReferenceData(sdict):
def __init__(self, model_class, **kwargs):
self.model_class = model_class
super(ReferenceData, self).__init__(**kwargs)
@cachedprop
def dbset(self):
if self.method:
return self.method(self.model_class)
return self.model_class.db
@cachedprop
def model_instance(self):
if self.method:
return self.dbset._model_._instance_()
return self.dbset[self.model]._model_
def _load_params_json(self, data):
try:
params = Parsers.get_for('json')(data)
except Exception:
params = {}
return sdict(params), sdict()
def _load_params_form_urlencoded(self, data):
rv = sdict()
for key, values in parse_qs(
data.decode(), keep_blank_values=True
).items():
if len(values) == 1:
rv[key] = values[0]
continue
rv[key] = values
return rv, sdict()
def query_params(self):
rv = sdict()
for key, values in parse_qs(
self._scope['query_string'].decode('ascii'), keep_blank_values=True
).items():
if len(values) == 1:
rv[key] = values[0]
continue
rv[key] = values
return rv
def __init__(self):
self.status = 200
self.cookies = SimpleCookie()
self.headers = {'Content-Type': 'text/html; charset=utf-8'}
self.meta = sdict()
self.meta_prop = sdict()
def __init__(self):
self.status = 200
self.cookies = SimpleCookie()
self.headers = {'Content-Type': 'text/html; charset=utf-8'}
self.meta = sdict()
self.meta_prop = sdict()