MCPcopy Index your code
hub / github.com/webpy/webpy / _delegate

Method _delegate

web/application.py:479–513  ·  view source on GitHub ↗
(self, f, fvars, args=[])

Source from the content-addressed store, hash-verified

477 ctx.app_stack = []
478
479 def _delegate(self, f, fvars, args=[]):
480 def handle_class(cls):
481 meth = web.ctx.method
482 if meth == "HEAD" and not hasattr(cls, meth):
483 meth = "GET"
484 if not hasattr(cls, meth):
485 raise web.nomethod(cls)
486 tocall = getattr(cls(), meth)
487 return tocall(*args)
488
489 if f is None:
490 raise web.notfound()
491 elif isinstance(f, application):
492 return f.handle_with_processors()
493 elif isclass(f):
494 return handle_class(f)
495 elif isinstance(f, str):
496 if f.startswith("redirect "):
497 url = f.split(" ", 1)[1]
498 if web.ctx.method == "GET":
499 x = web.ctx.env.get("QUERY_STRING", "")
500 if x:
501 url += "?" + x
502 raise web.redirect(url)
503 elif "." in f:
504 mod, cls = f.rsplit(".", 1)
505 mod = __import__(mod, None, None, [""])
506 cls = getattr(mod, cls)
507 else:
508 cls = fvars[f]
509 return handle_class(cls)
510 elif hasattr(f, "__call__"):
511 return f()
512 else:
513 return web.notfound()
514
515 def _match(self, mapping, value):
516 for pat, what in mapping:

Callers 2

handleMethod · 0.95
handleMethod · 0.80

Calls 4

fFunction · 0.85
notfoundMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected