dirk / constrictor

Powerful Python web-development framework.

This URL has Read+Write access

dirk (author)
Mon Nov 02 16:06:32 -0800 2009
commit  951e14297914f62a5719aa54b9d157d6ea59b1e3
tree    08e5d2bce824371269cd6f150f23e39733feb425
parent  551a487b30dd44b5c32ed943ebf31984d6f6d9c0
constrictor / request.py
100644 34 lines (33 sloc) 0.943 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Request(object):
  """
# Dict of headers sent with the request from the client
request_headers = {}
# List of headers
headers = []
status = 200
# Raw path (EG: "/test/abc/123")
path = None
# GET/POST variables
get = {}
post = {}
# User agent of the client
user_agent = ''
# IP address of client
ip_address = ''
# Actual Constrictor instance
instance = None
# Instance of the server; used to grab host, port, etc.
server_instance = None
# Session class
session = {}
# Actual method being executed, set during Constrictor.process.
method = None
"""
  def redirect(self, location, status = 302):
    self.headers.append('Location: ' + location.strip())
    self.path = self.path + '" -> "%s' % location
    self.status = status
    data = self.instance.config['Pages']['Redirect']
    data = data.replace('{path}', location)
    data = data.replace('{status}', str(status))
    return data