How to use the emmett.utils.cachedprop 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 / orm / migrations / revisions.py View on Github external
    @cachedprop
    def _real_bases(self):
        self._revision_map
        return self._real_bases
github emmett-framework / emmett / emmett / asgi / handlers.py View on Github external
    @cachedprop
    def error_handler(self):
        return (
            self._debug_handler if self.app.debug else self.exception_handler)
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
    @cachedprop
    def now(self):
        return pendulum.instance(self._scope['emt.now'])
github emmett-framework / emmett / emmett / orm / migrations / revisions.py View on Github external
    @cachedprop
    def _revision_map(self):
        rmap = {}

        heads = OrderedSet()
        _real_heads = OrderedSet()
        self.bases = ()
        self._real_bases = ()

        #has_branch_labels = set()
        #has_depends_on = set()
        for revision in self._generator():

            if revision.revision in rmap:
                self.app.log.warn(
                    "Revision %s is present more than once" % revision.revision
                )
github emmett-framework / emmett / emmett / debug.py View on Github external
    @cachedprop
    def sourcelines(self):
        try:
            with open(self.filename, 'rb') as file:
                source = file.read().decode('utf8')
        except IOError:
            source = ''
        return source.splitlines()
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
    @cachedprop
    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 / asgi / handlers.py View on Github external
    @cachedprop
    def language(self):
        return self.websocket.accept_language.best_match(
            list(_translator_instance._t.all_languages))
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
    @cachedprop
    def now_local(self):
        return self.now.in_timezone(pendulum.local_timezone())
github emmett-framework / emmett / emmett / wrappers / request.py View on Github external
    @cachedprop
    def content_length(self):
        return self.headers.get('content_length', 0, cast=int)
github emmett-framework / emmett / emmett / debug.py View on Github external
    @cachedprop
    def render_locals(self):
        rv = dict()
        for k, v in self.locals.items():
            try:
                rv[k] = str(v)
            except Exception:
                rv[k] = ''
        return rv