Revision d50ed8d4 snf-pithos-app/pithos/api/delegate.py

b/snf-pithos-app/pithos/api/delegate.py
1 1
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2
# 
2
#
3 3
# Redistribution and use in source and binary forms, with or
4 4
# without modification, are permitted provided that the following
5 5
# conditions are met:
6
# 
6
#
7 7
#   1. Redistributions of source code must retain the above
8 8
#      copyright notice, this list of conditions and the following
9 9
#      disclaimer.
10
# 
10
#
11 11
#   2. Redistributions in binary form must reproduce the above
12 12
#      copyright notice, this list of conditions and the following
13 13
#      disclaimer in the documentation and/or other materials
14 14
#      provided with the distribution.
15
# 
15
#
16 16
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 17
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 18
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
......
25 25
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 26
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 27
# POSSIBILITY OF SUCH DAMAGE.
28
# 
28
#
29 29
# The views and conclusions contained in the software and
30 30
# documentation are those of the authors and should not be
31 31
# interpreted as representing official policies, either expressed
......
46 46

  
47 47
logger = logging.getLogger(__name__)
48 48

  
49

  
49 50
def delegate_to_login_service(request):
50 51
    url = AUTHENTICATION_URL
51 52
    users = AUTHENTICATION_USERS
52 53
    if users or not url:
53 54
        return HttpResponseNotFound()
54
    
55

  
55 56
    p = urlparse(url)
56 57
    if request.is_secure():
57 58
        proto = 'https://'
......
61 62
    uri = proto + p.netloc + '/login?' + urlencode(params)
62 63
    return HttpResponseRedirect(uri)
63 64

  
65

  
64 66
@csrf_exempt
65 67
def delegate_to_feedback_service(request):
66 68
    url = AUTHENTICATION_URL
67 69
    users = AUTHENTICATION_USERS
68 70
    if users or not url:
69 71
        return HttpResponseNotFound()
70
    
72

  
71 73
    p = urlparse(url)
72 74
    if request.is_secure():
73 75
        proto = 'https://'
74 76
    else:
75 77
        proto = 'http://'
76
    
78

  
77 79
    uri = proto + p.netloc + '/im/service/api/v2.0/feedback'
78
    headers = { 'X-Auth-Token' : SERVICE_TOKEN }
80
    headers = {'X-Auth-Token': SERVICE_TOKEN}
79 81
    values = dict([(k, v) for k, v in request.POST.items()])
80 82
    data = urllib.urlencode(values)
81 83
    req = urllib2.Request(uri, data, headers)
......
87 89
    except urllib2.URLError, e:
88 90
        logger.exception(e)
89 91
        return HttpResponse(status=e.reason)
90
    return HttpResponse()
92
    return HttpResponse()

Also available in: Unified diff