Rapatriement des données w.c.s.
This commit is contained in:
parent
d8937de390
commit
bab7cdfc9d
|
@ -0,0 +1,7 @@
|
|||
from ldap3 import Server, Connection, ALL
|
||||
|
||||
def ldap_init():
|
||||
server = Server('spare.entrouvert.lan')
|
||||
conn = Connection(server)
|
||||
res = conn.bind()
|
||||
return res
|
|
@ -1,9 +1,12 @@
|
|||
import os
|
||||
import json
|
||||
import urllib
|
||||
import urllib2
|
||||
import urlparse
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
import os
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
@ -12,6 +15,7 @@ from django.views.generic import View, UpdateView, CreateView
|
|||
|
||||
# Add library search path entry?
|
||||
from passerelle import utils
|
||||
from .utils import ldap_init
|
||||
|
||||
#from .forms import QueryForm
|
||||
#from .models import CsvDataSource, Query
|
||||
|
@ -22,13 +26,34 @@ from passerelle import utils
|
|||
# derive csv connector
|
||||
# use ldap3 instead of python-ldap
|
||||
|
||||
wcs_base = "http://wcs.example.com"
|
||||
form_slug = "/traitement/"
|
||||
|
||||
# Create your views here.
|
||||
def dummy_view(request):
|
||||
return HttpResponse("Dummy LDAP connector view.")
|
||||
|
||||
# Simple w.c.s. <-> Passerelle REST communication
|
||||
def get_form_entry(wcs_entry_id):
|
||||
data_uri = "/api/forms"+form_slug+str(wcs_entry_id)
|
||||
geturl = wcs_base+data_uri
|
||||
|
||||
#opener = urllib2.build_opener(urllib2.HTTPHandler)
|
||||
|
||||
req = urllib2.urlopen(geturl)
|
||||
#req.add_header("Accept", "application/json")
|
||||
|
||||
#response = opener.open(req)
|
||||
|
||||
return req.read()
|
||||
#return geturl
|
||||
|
||||
def wcs(request, slug="", wcs_entry_id=0):
|
||||
#TODO
|
||||
return HttpResponse("Querying w.c.s")
|
||||
# Initiate the LDAP connection:
|
||||
#res = ldap_init() #OK
|
||||
|
||||
res = get_form_entry(wcs_entry_id)
|
||||
return HttpResponse("Querying w.c.s "+str(res))
|
||||
|
||||
class LDAPView(View, SingleObjectMixin):
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
|
Reference in New Issue