File: webapp.py

package info (click to toggle)
fs-uae-arcade 3.1.63-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 24,456 kB
  • sloc: python: 56,011; makefile: 170
file content (41 lines) | stat: -rw-r--r-- 747 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import bottle
import threading


class Request(object):
    def __init__(self):
        pass


def get_request():
    return _thread_local.request


class Proxy(object):
    def __init__(self, func):
        self._func = func

    def __getattr__(self, name):
        return getattr(self._func(), name)

    def __setattr__(self, name, value):
        return setattr(self._func(), name, value)


class WebApp(object):
    def __init__(self):
        pass

    def route(self, path):
        def wrapper(func):
            def wrapper2():
                print("wrapper", func)
                return func()

            return bottle.route(path)(wrapper2)

        return wrapper


_thread_local = threading.local()
# request = Proxy(get_request)