Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2409: generic.diff

File generic.diff, 688 bytes (added by cleverdevil, 2 years ago)
  • tg/jsonify.py

    diff -r 62c3c2c378b4 tg/jsonify.py
    a b  
    3636        else: 
    3737            return JSONEncoder.default(self, obj) 
    3838 
    39 _instance = GenericJSON() 
     39 
     40# Generic Function JSON Encoder class 
     41 
     42try: 
     43    from simplegeneric import generic 
     44 
     45    _default = GenericJSON() 
     46 
     47    @generic 
     48    def jsonify(obj): 
     49        return _default.default(obj) 
     50 
     51    class GenericFunctionJSON(GenericJSON): 
     52        def default(self, obj): 
     53            return jsonify(obj) 
     54 
     55    _instance = GenericFunctionJSON() 
     56except ImportError: 
     57    _instance = GenericJSON() 
    4058 
    4159 
    4260# General encoding functions