def default(self, o, **settings): if proxy.isProxy(o, JSONEncoderSettingsProxy): o, settings = proxy.getProxiedObject(o), o.__json_settings__ adapter = self.adapters.lookup_adapter(providedBy(o)) if adapter is None: raise TypeError("%r is not JSON serializable" % o) return adapter(o, **settings)
def _adapter_hook(self, provided, obj): adapter = self.registry.lookup1(interface.providedBy(obj), provided, '') if callable(adapter): return adapter(obj) else: adapter.application = self return adapter
def default(self, o, **settings): if proxy.isProxy(o, JSONEncoderSettingsProxy): o, settings = proxy.getProxiedObject(o), o.__json_settings__ if proxy.isProxy(o): o = proxy.removeAllProxies(o) return o adapter = self.adapters.lookup_adapter(providedBy(o)) if adapter is None: raise TypeError("%r is not JSON serializable" % o) return adapter(o, **settings)