I want to create my own decorotar which will be "extend" @route decorator from Bottle framework. I have problem with sementic. This code dosen't work and I don't have idea how to repair it.
from bottle import route, run
class router(object):
def __init__(self, f):
self.f = f
def __call__(self, *args):
self.f(*args)
@router('/hello')
def hello():
return "Hello World!"
run(host='localhost', port=8080, debug=True)
edit: Second try:
from bottle import Bottle
class B(Bottle):
def route(self,*args):
def f(*args):
print "My Text" #This dosen't print
super(B, self).route(*args)
return f
b = B()
@b.route('/hello')
def hello():
return "Hello World!x"
b.run(host='localhost', port=8080, debug=True)
Also dosen't work.