How to use the emmett.datastructures.sdict function in emmett

To help you get started, we’ve selected a few emmett examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
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()
github emmett-framework / emmett / emmett / app.py View on Github external
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]
github emmett-framework / emmett / emmett / app.py View on Github external
#: 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
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
def _load_params_missing(self, data):
        return sdict(), sdict()
github emmett-framework / emmett / emmett / orm / helpers.py View on Github external
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_
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
def _load_params_json(self, data):
        try:
            params = Parsers.get_for('json')(data)
        except Exception:
            params = {}
        return sdict(params), sdict()
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
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()
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
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
github emmett-framework / emmett / emmett / wrappers / response.py View on Github external
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()
github emmett-framework / emmett / emmett / wrappers / response.py View on Github external
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()