MCPcopy Create free account
hub / github.com/datapane/datapane / apply

Method apply

python-client/src/datapane/_vendor/bottle.py:1993–2015  ·  view source on GitHub ↗
(self, callback, route)

Source from the content-addressed store, hash-verified

1991 " apply.")
1992
1993 def apply(self, callback, route):
1994 dumps = self.json_dumps
1995 if not self.json_dumps: return callback
1996
1997 @functools.wraps(callback)
1998 def wrapper(*a, **ka):
1999 try:
2000 rv = callback(*a, **ka)
2001 except HTTPResponse as resp:
2002 rv = resp
2003
2004 if isinstance(rv, dict):
2005 #Attempt to serialize, raises exception on failure
2006 json_response = dumps(rv)
2007 #Set content type only if serialization successful
2008 response.content_type = 'application/json'
2009 return json_response
2010 elif isinstance(rv, HTTPResponse) and isinstance(rv.body, dict):
2011 rv.body = dumps(rv.body)
2012 rv.content_type = 'application/json'
2013 return rv
2014
2015 return wrapper
2016
2017
2018class TemplatePlugin(object):

Callers 9

demoFunction · 0.45
_make_callbackMethod · 0.45
_handleMethod · 0.45
_castMethod · 0.45
downcast_numbersFunction · 0.45
parse_categoriesFunction · 0.45
obj_to_strFunction · 0.45
parse_timedeltaFunction · 0.45
parse_datesFunction · 0.45

Calls

no outgoing calls

Tested by 2

parse_timedeltaFunction · 0.36
parse_datesFunction · 0.36