212 if param in self.no_script_form_params and val: |
212 if param in self.no_script_form_params and val: |
213 val = self.no_script_form_param(param, val) |
213 val = self.no_script_form_param(param, val) |
214 if param == '_cwmsgid': |
214 if param == '_cwmsgid': |
215 self.set_message_id(val) |
215 self.set_message_id(val) |
216 elif param == '__message': |
216 elif param == '__message': |
|
217 warn('[3.13] __message in request parameter is deprecated (may ' |
|
218 'only be given to .build_url). Seeing this message usualy ' |
|
219 'means your application hold some <form> where you should ' |
|
220 'replace use of __message hidden input by form.set_message, ' |
|
221 'so new _cwmsgid mechanism is properly used', |
|
222 DeprecationWarning) |
217 self.set_message(val) |
223 self.set_message(val) |
218 else: |
224 else: |
219 self.form[param] = val |
225 self.form[param] = val |
220 |
226 |
221 def no_script_form_param(self, param, value): |
227 def no_script_form_param(self, param, value): |
281 @cached |
287 @cached |
282 def redirect_message_id(self): |
288 def redirect_message_id(self): |
283 return make_uid() |
289 return make_uid() |
284 |
290 |
285 def set_redirect_message(self, msg): |
291 def set_redirect_message(self, msg): |
|
292 # TODO - this should probably be merged with append_to_redirect_message |
286 assert isinstance(msg, unicode) |
293 assert isinstance(msg, unicode) |
287 msgid = self.redirect_message_id() |
294 msgid = self.redirect_message_id() |
288 self.session.data[msgid] = msg |
295 self.session.data[msgid] = msg |
289 return msgid |
296 return msgid |
290 |
297 |
291 def append_to_redirect_message(self, msg): |
298 def append_to_redirect_message(self, msg): |
292 msgid = self.redirect_message_id() |
299 msgid = self.redirect_message_id() |
293 currentmsg = self.session.data.get(msgid) |
300 currentmsg = self.session.data.get(msgid) |
294 if currentmsg is not None: |
301 if currentmsg is not None: |
295 currentmsg = '%s %s' % (currentmsg, msg) |
302 currentmsg = u'%s %s' % (currentmsg, msg) |
296 else: |
303 else: |
297 currentmsg = msg |
304 currentmsg = msg |
298 self.session.data[msgid] = currentmsg |
305 self.session.data[msgid] = currentmsg |
299 return msgid |
306 return msgid |
300 |
307 |
621 cbname, nodeid, js.loadxhtml(url, None, 'get', replacemode)) |
628 cbname, nodeid, js.loadxhtml(url, None, 'get', replacemode)) |
622 self.html_headers.add_post_inline_script(jscode) |
629 self.html_headers.add_post_inline_script(jscode) |
623 return "javascript: %s()" % cbname |
630 return "javascript: %s()" % cbname |
624 |
631 |
625 # urls/path management #################################################### |
632 # urls/path management #################################################### |
|
633 |
|
634 def build_url(self, *args, **kwargs): |
|
635 """return an absolute URL using params dictionary key/values as URL |
|
636 parameters. Values are automatically URL quoted, and the |
|
637 publishing method to use may be specified or will be guessed. |
|
638 """ |
|
639 if '__message' in kwargs: |
|
640 msg = kwargs.pop('__message') |
|
641 kwargs['_cwmsgid'] = self.set_redirect_message(msg) |
|
642 return super(CubicWebRequestBase, self).build_url(*args, **kwargs) |
626 |
643 |
627 def url(self, includeparams=True): |
644 def url(self, includeparams=True): |
628 """return currently accessed url""" |
645 """return currently accessed url""" |
629 return self.base_url() + self.relative_path(includeparams) |
646 return self.base_url() + self.relative_path(includeparams) |
630 |
647 |