/[glsr]/trunk/harmonious/_requestfactory.py
Gentoo

Contents of /trunk/harmonious/_requestfactory.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations) (download) (as text)
Thu Jun 16 00:41:45 2005 UTC (9 years, 4 months ago) by port001
File MIME type: text/x-python
File size: 1670 byte(s)
Convert Header to Id
1 __id__ = '$Id$'
2 __version__ = '$Revision: $'
3 __modulename__ = 'RequestFactory'
4
5 import os
6 import urlparse
7
8 from harmonious import harm
9 from harmonious._request import Request
10
11 class RequestFactory:
12
13 def __init__(self, req_obj):
14
15 self.__base_req = req_obj
16 self.__request = Request()
17 self.__url_elements = ()
18
19 def construct(self):
20
21 self.__decode_url()
22 self.__decode_elements()
23 self.__request._baseRequest = self.__base_req
24
25 return self.__request
26
27 def __decode_url(self):
28
29 self.__url_elements = urlparse.urlsplit(self.__base_req.path,
30 'http', True)
31
32 def __decode_elements(self):
33
34 # Queries
35 if len(self.__url_elements[3]) != 0:
36
37 queries = self.__url_elements[3].split('&')
38
39 for query in queries:
40
41 try:
42 (key, value) = query.split('=')
43 except ValueError:
44 key = query
45 value = None
46
47 if not self.__request.queries.has_key(key):
48
49 self.__request.queries[key] = u'%s' % value
50
51 # Fragment
52 if len(self.__url_elements[4]) != 0:
53
54 self.__request.fragment = u'%s' % self.__url_elements[4]
55
56 # Path - Including the file, PathFilter will split these
57 self.__request.path = self.__url_elements[2]
58
59 # File
60 if self.__request.path[-1] != '/':
61
62 self.__request.file = os.path.basename(self.__request.path)
63
64 # Absolute path
65 self.__request.abs_path = "%s%s" % (harm.config.server['DomainPath'], self.__request.path)

Properties

Name Value
svn:keywords Id

  ViewVC Help
Powered by ViewVC 1.1.20