Пример #1
0
def settings(request):
    try:
        json = dict(method="get_settings",id=None,params=[])
        from webob import Request as Requ
        req = Requ.blank("http://localhost:7777/")
        req.method = 'POST'
        req.content_type = 'application/json'
        from simplejson import loads, dumps
        req.body = dumps(json)
        from wsgiproxy.exactproxy import proxy_exact_request
        resp = req.get_response(proxy_exact_request)
        json = loads(resp.body)
        all_list = json['result']
        DBContainer.objects.all().delete()
        dbContainer = DBContainer(ip_address=all_list['ip_addr'], 
                                  created=True, 
                                  session_id=request.session.session_key,
                                  port = all_list['port'],
                                  name = all_list['name'],
                                  uuid = all_list['uuid'],
                                  do_mimetype_container = all_list['do_mimetype_container'],
                                  transcoding = all_list['transcoding'],
                                  max_path = all_list['max_child_items'],
                                  enable_inotify= all_list['enable_inotify']
                                  )
        DBAddress.objects.all().delete()
        DBAddress(ip_address=all_list['ip_addr'],
                  port = all_list['port']).save()
        dbContainer.save()
    except Exception, e:
        pass
Пример #2
0
def update(request):
    print "update"
    response = HttpResponse()
    response['Content-Type'] = "text/javascript"
    json = serializers.serialize("json", BlogPost.objects.all())
    #from JSONRPCServer import JsonClient
    #client = JsonClient()
    #client.connect()
    #client.sendObject(json)
    response.write(json)
    all_list = DBContainer.objects.all()
    if len(all_list) == 0:
        DBContainer.create()
    all_list = DBContainer.objects.all()    
    print all_list
    return response
Пример #3
0
def saveSettings(request):
    if request.is_ajax() and request.POST:
        json = json2.dumps(request.POST)
        #TODO send this json to server and load to db
        #return HttpResponseBadRequest('Only POST accepted')
        from webob import Request as Requ
        req = Requ.blank("http://localhost:7777/")
        req.method = 'POST'
        req.content_type = 'application/json'
        #server_name, transcoding='no', ip_addr = None, port = 0, enable_inotify = True, max_child_items = 300
        lista = request.POST.lists()
        json = dict(method="set_settings",id=None,params=[lista])
        from simplejson import loads, dumps
        req.body = dumps(json)
        from wsgiproxy.exactproxy import proxy_exact_request
        resp = req.get_response(proxy_exact_request)
        json = loads(resp.body)
        all_list = json['result']
        response = HttpResponse()
        response['Content-Type'] = "application/json"
        if all_list and not 'False' in all_list:
            DBContainer.objects.all().delete()
            dbContainer = DBContainer(ip_address=all_list['ip_addr'], 
                                  created=True, 
                                  session_id=request.session.session_key,
                                  port = all_list['port'],
                                  name = all_list['name'],
                                  uuid = all_list['uuid'],
                                  do_mimetype_container = all_list['do_mimetype_container'],
                                  transcoding = all_list['transcoding'],
                                  max_path = all_list['max_child_items'],
                                  enable_inotify= all_list['enable_inotify']
                                  )
            DBAddress.objects.all().delete()
            DBAddress(ip_address=all_list['ip_addr'], port = all_list['port']).save()
            dbContainer.save()
            response.write(json2.dumps(all_list))
            return response
        response = HttpResponse()
        response['Content-Type'] = "application/json"
        response.write("false")
        return response