79 return [v for v in value if v != INTERNAL_FIELD_VALUE] |
79 return [v for v in value if v != INTERNAL_FIELD_VALUE] |
80 |
80 |
81 |
81 |
82 |
82 |
83 class CubicWebRequestBase(DBAPIRequest): |
83 class CubicWebRequestBase(DBAPIRequest): |
84 """abstract HTTP request, should be extended according to the HTTP backend""" |
84 """abstract HTTP request, should be extended according to the HTTP backend |
|
85 Immutable attributes that describe the received query and generic configuration |
|
86 """ |
85 ajax_request = False # to be set to True by ajax controllers |
87 ajax_request = False # to be set to True by ajax controllers |
86 |
88 |
87 def __init__(self, vreg, https, form=None): |
89 def __init__(self, vreg, https, form=None): |
|
90 """ |
|
91 :vreg: Vregistry, |
|
92 :https: boolean, s this a https request |
|
93 :form: Forms value |
|
94 """ |
88 super(CubicWebRequestBase, self).__init__(vreg) |
95 super(CubicWebRequestBase, self).__init__(vreg) |
|
96 #: (Boolean) Is this an https request. |
89 self.https = https |
97 self.https = https |
|
98 #: User interface property (vary with https) (see uiprops_) |
|
99 self.uiprops = None |
|
100 #: url for serving datadir (vary with https) (see resources_) |
|
101 self.datadir_url = None |
90 if https: |
102 if https: |
91 self.uiprops = vreg.config.https_uiprops |
103 self.uiprops = vreg.config.https_uiprops |
92 self.datadir_url = vreg.config.https_datadir_url |
104 self.datadir_url = vreg.config.https_datadir_url |
93 else: |
105 else: |
94 self.uiprops = vreg.config.uiprops |
106 self.uiprops = vreg.config.uiprops |
95 self.datadir_url = vreg.config.datadir_url |
107 self.datadir_url = vreg.config.datadir_url |
96 # raw html headers that can be added from any view |
108 #: raw html headers that can be added from any view |
97 self.html_headers = HTMLHead(self) |
109 self.html_headers = HTMLHead(self) |
98 # form parameters |
110 #: form parameters |
99 self.setup_params(form) |
111 self.setup_params(form) |
100 # dictionary that may be used to store request data that has to be |
112 #: dictionary that may be used to store request data that has to be |
101 # shared among various components used to publish the request (views, |
113 #: shared among various components used to publish the request (views, |
102 # controller, application...) |
114 #: controller, application...) |
103 self.data = {} |
115 self.data = {} |
104 # search state: 'normal' or 'linksearch' (eg searching for an object |
116 #: search state: 'normal' or 'linksearch' (eg searching for an object |
105 # to create a relation with another) |
117 #: to create a relation with another) |
106 self.search_state = ('normal',) |
118 self.search_state = ('normal',) |
107 # page id, set by htmlheader template |
119 #: page id, set by htmlheader template |
108 self.pageid = None |
120 self.pageid = None |
109 self._set_pageid() |
121 self._set_pageid() |
110 # prepare output header |
122 # prepare output header |
|
123 #: Header used for the final response |
111 self.headers_out = Headers() |
124 self.headers_out = Headers() |
112 |
125 |
113 def _set_pageid(self): |
126 def _set_pageid(self): |
114 """initialize self.pageid |
127 """initialize self.pageid |
115 if req.form provides a specific pageid, use it, otherwise build a |
128 if req.form provides a specific pageid, use it, otherwise build a |
131 self.ajax_request = value |
144 self.ajax_request = value |
132 json_request = property(_get_json_request, _set_json_request) |
145 json_request = property(_get_json_request, _set_json_request) |
133 |
146 |
134 @property |
147 @property |
135 def authmode(self): |
148 def authmode(self): |
|
149 """Authentification mode of the instance |
|
150 |
|
151 (see `Configuring the Web server`_)""" |
136 return self.vreg.config['auth-mode'] |
152 return self.vreg.config['auth-mode'] |
|
153 |
|
154 # Various variable generator. |
137 |
155 |
138 @property |
156 @property |
139 def varmaker(self): |
157 def varmaker(self): |
140 """the rql varmaker is exposed both as a property and as the |
158 """the rql varmaker is exposed both as a property and as the |
141 set_varmaker function since we've two use cases: |
159 set_varmaker function since we've two use cases: |