Ejemplo n.º 1
0
def invoke(request):
    form = forms.RequestForm(request.GET)
    if form.is_valid():
        query = RequestProcessor(request).get_arguments_no_validation()
        query['pId'] = form.cleaned_data.get('datastream_revision_id')
        limit = form.cleaned_data.get('limit')
        if limit:
            query['pLimit'] = limit

        ivk = engine_invoke(query)
        # Sometimes there is no answer. Maybe engine is down
        if ivk is None:
            contents = '{"Error":"No invoke"}'
            typen = "json"
        else:
            contents, typen = ivk

        return HttpResponse(contents, mimetype=typen)
    else:
        return HttpResponse('Error! No valid form')
Ejemplo n.º 2
0
def export_to(datastream_id, request, output):

    try:
        datastreamrevision_id = DataStreamRevision.objects.get_last_published_id(datastream_id)
        datastream = DataStreamDBDAO().get(request.auth_manager.language, datastream_revision_id=datastreamrevision_id)
    except:
        raise Http404
    else:
        uri = request.build_absolute_uri()
        
        query = {'pId': datastreamrevision_id, 'pOutput': output.upper()}

        arguments = RequestProcessor(request).get_arguments(datastream["parameters"])
        if arguments:
            query.update(arguments)

        filter = request.REQUEST.get('pFilter0', None)
        if filter:
            query['pFilter0'] = unicode(filter).encode('utf-8')

        return engine_invoke(query, output)
Ejemplo n.º 3
0
def updategrid(request):
    query = dict()
    query['pId'] = request.REQUEST.get('datastream_id')
    query['pLimit'] = request.REQUEST.get('rp')
    query['pPage'] = int(request.REQUEST.get('page')) - 1

    search = request.REQUEST.get('query', None)
    if search:
        query['pFilter0'] = '%s[contains]%s' % (request.REQUEST.get('qtype', 'column0'), search)

    sortname = request.REQUEST.get('sortname', None)
    sortorder = request.REQUEST.get('sortorder', None)
    if sortname:
        query['pOrderBy'] = sortname
        query['pOrderType'] = {None: 'A', 'asc': 'A', 'desc': 'D'}[sortorder]

    contents, mimetype = engine_invoke(RequestProcessor(request).get_arguments_no_validation(query))
    if not contents:
        contents = {"rows": [], "total": 1, "page": 1}
        mimetype = "application/json"
    return HttpResponse(jsonToGrid(contents, query['pPage'] + 1), mimetype=mimetype)