semvec/pypi-packages huggingface dataset:
pywe-storage 1.0.1
Wechat Storage Module for Python.
Keywords: Wechat Weixin Storage

============
pywe-storage
============

Wechat Storage Module for Python.

Installation
============

::

    pip install pywe-storage


Usage
=====

MemoryStorage::

    In [1]: from pywe_storage import MemoryStorage

    In [2]: storage = MemoryStorage()

    In [3]: storage.set('xx:oo', {'a': 1, 'b': 2})

    In [4]: storage.get('xx:oo')
    Out[4]: {'a': 1, 'b': 2}


RedisStorage::

    In [1]: import redis_extensions as redis

    In [2]: r = redis.StrictRedisExtensions(host='localhost', port=6379, db=0)

    In [3]: from pywe_storage import RedisStorage

    In [4]: storage = RedisStorage(r)

    In [5]: storage.set('xx:oo', {'a': 1, 'b': 2})

    In [6]: storage.get('xx:oo')
    Out[6]: {u'a': 1, u'b': 2}

    In [7]: r.get('pywe:xx:oo')
    Out[7]: '{"a": 1, "b": 2}'


Method
======

::

    class MemoryStorage(BaseStorage):
        def __init__(self, prefix='pywe'):

    class RedisStorage(BaseStorage):
        def __init__(self, redis, prefix='pywe'):
django-json-response 1.1.5
DIY Django's JsonResponse and JsonpResponse
Keywords: django-json-response django-jsonp-response

====================
django-json-response
====================

django-json-response
====================

* JsonResponse is New in Django 1.7

* Ref: https://docs.djangoproject.com/en/1.8/ref/request-response/#jsonresponse-objects

Installation
============

::

    pip install django-json-response


Warning
=======

::

    Since Version 1.1.3, the JsonpResponse return Object replace of String.

    "{}('{}')" ==> '{}({});'


Usage
=====

::

    from json_response import JsonResponse

    def json_view(request):
        objs = SomeModel.objects.all()

        return JsonResponse({
            'status': 200,
            'message': u'成功',
            'data': {
                'data1': 'xxx',
                'data2': 'ooo',
                'objs': [obj.data for obj in objs]
            }
        })


    or


    from json_response import JsonpResponse

    def jsonp_view(request):
        callback = request.GET.get('callback', '')

        objs = SomeModel.objects.all()

        return JsonpResponse(callback, {
            'status': 200,
            'message': u'成功',
            'data': {
                'data1': 'xxx',
                'data2': 'ooo',
                'objs': [obj.data for obj in objs]
            }
        })

    or

    from json_response import json_response, jsonp_response, auto_response

    @json_response
    def json_view(request):
        objs = SomeModel.objects.all()

        return {
            'status': 200,
            'message': u'成功',
            'data': {
                'data1': 'xxx',
                'data2': 'ooo',
                'objs': [obj.data for obj in objs]
            }
        }

    @jsonp_response
    def jsonp_view(request):
        objs = SomeModel.objects.all()

        return {
            'status': 200,
            'message': u'成功',
            'data': {
                'data1': 'xxx',
                'data2': 'ooo',
                'objs': [obj.data for obj in objs]
            }
        }

    @auto_response
    def jsonp_view(request):
        objs = SomeModel.objects.all()

        return {
            'status': 200,
            'message': u'成功',
            'data': {
                'data1': 'xxx',
                'data2': 'ooo',
                'objs': [obj.data for obj in objs]
            }
        }