root/galaxy-central/eggs/Paste-1.6-py2.6.egg/paste/pony.py

リビジョン 3, 2.2 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
2# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
3"""
4We have a pony and/or a unicorn.
5"""
6from paste.request import construct_url
7
8PONY = """
9eJyFkkFuxCAMRfdzCisbJxK2D5D2JpbMrlI3XXQZDt9PCG0ySgcWIMT79rcN0XClUJlZRB9jVmci
10FmV19khjgRFl0RzrKmqzvY8lRUWFlXvCrD7UbAQR/17NUvGhypAF9og16vWtkC8DzUayS6pN3/dR
11ki0OnpzKjUBFpmlC7zVFRNL1rwoq6PWXXQSnIm9WoTzlM2//ke21o5g/l1ckRhiPbkDZXsKIR7l1
1236hF9uMhnRiVjI8UgYjlsIKCrXXpcA9iX5y7zMmtG0fUpW61Ssttipf6cp3WARfkMVoYFryi2a+w
13o/2dhW0OXfcMTnmh53oR9egzPs+qkpY9IKxdUVRP5wHO7UDAuI6moA2N+/z4vtc2k8B+AIBimVU=
14"""
15
16UNICORN = """
17eJyVVD1vhDAM3e9XeAtIxB5P6qlDx0OMXVBzSpZOHdsxP762E0JAnMgZ8Zn37OePAPC60eV1Dl5b
18SS7fB6DmQNGhtegpNlPIQS8HmkYGdSqNqDF9wcMYus4TuBYGsZwIPqXfEoNir5K+R3mbzhlR4JMW
19eGpikPpn9wHl2sDgEH1270guZwzKDRf3nTztMvfI5r3fJqEmNxdCyISBcWjNgjPG8Egg2hgT3mJi
20KBwNvmPB1hbWJ3TwBfMlqdTzxNyDE2H8zOD5HA4KkqJGPVY/TwnxmPA82kdSJNj7zs+R0d1pB+JO
21xn2DKgsdxAfFS2pfTSD0Fb6Uzv7dCQSvE5JmZQEQ90vNjBU1GPuGQpCPS8cGo+dQgjIKqxnJTXbw
22ucFzPFVIJXtzk6BXKGPnYsKzvFmGx7A0j6Zqvlvk5rETXbMWTGWj0RFc8QNPYVfhJfMMniCPazWJ
23lGtPZecIGJWW6oL2hpbWRZEkChe8eg5Wb7xx/MBZBFjxeZPEss+mRQ3Uhc8WQv684seSRO7i3nb4
247HlKUg8sraz47LmXyh8S0somADvoUpoHjGWl+rUkF0H+EIf/gbyyMg58BBk6L634/fkHUCodMw==
25"""
26
27
28class PonyMiddleware(object):
29
30    def __init__(self, application):
31        self.application = application
32
33    def __call__(self, environ, start_response):
34        path_info = environ.get('PATH_INFO', '')
35        if path_info == '/pony':
36            url = construct_url(environ, with_query_string=False)
37            if 'horn' in environ.get('QUERY_STRING', ''):
38                data = UNICORN
39                link = 'remove horn!'
40            else:
41                data = PONY
42                url += '?horn'
43                link = 'add horn!'
44            msg = data.decode('base64').decode('zlib')
45            msg = '<pre>%s\n<a href="%s">%s</a></pre>' % (
46                msg, url, link)
47            start_response('200 OK', [('content-type', 'text/html')])
48            return [msg]
49        else:
50            return self.application(environ, start_response)
51
52def make_pony(app, global_conf):
53    """
54    Adds pony power to any application, at /pony
55    """
56    return PonyMiddleware(app)
57
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。