コード例 #1
0
ファイル: encoder.py プロジェクト: MechanisM/jsonpublish
 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)
コード例 #2
0
 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
コード例 #3
0
 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
コード例 #4
0
 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)