web/request.py
branchtls-sprint
changeset 1801 672acc730ce5
parent 1718 26ff2d292183
child 1977 606923dff11b
equal deleted inserted replaced
1800:05c36cf3c813 1801:672acc730ce5
    17 from rql.utils import rqlvar_maker
    17 from rql.utils import rqlvar_maker
    18 
    18 
    19 from logilab.common.decorators import cached
    19 from logilab.common.decorators import cached
    20 from logilab.common.deprecation import obsolete
    20 from logilab.common.deprecation import obsolete
    21 
    21 
       
    22 from logilab.mtconverter import html_escape
       
    23 
    22 from cubicweb.dbapi import DBAPIRequest
    24 from cubicweb.dbapi import DBAPIRequest
    23 from cubicweb.common.mail import header
    25 from cubicweb.common.mail import header
    24 from cubicweb.common.uilib import remove_html_tags
    26 from cubicweb.common.uilib import remove_html_tags
    25 from cubicweb.utils import SizeConstrainedList, HTMLHead
    27 from cubicweb.utils import SizeConstrainedList, HTMLHead
    26 from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit, RequestError,
    28 from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit,
    27                           StatusResponse)
    29                           RequestError, StatusResponse)
    28 
    30 
    29 _MARKER = object()
    31 _MARKER = object()
    30 
    32 
    31 
    33 
    32 def list_form_param(form, param, pop=False):
    34 def list_form_param(form, param, pop=False):
   476         for cssfile in cssfiles:
   478         for cssfile in cssfiles:
   477             if localfile:
   479             if localfile:
   478                 cssfile = self.datadir_url + cssfile
   480                 cssfile = self.datadir_url + cssfile
   479             add_css(cssfile, media)
   481             add_css(cssfile, media)
   480 
   482 
       
   483     def build_ajax_replace_url(self, nodeid, rql, vid, replacemode='replace',
       
   484                                **extraparams):
       
   485         """builds an ajax url that will replace `nodeid`s content
       
   486         :param nodeid: the dom id of the node to replace
       
   487         :param rql: rql to execute
       
   488         :param vid: the view to apply on the resultset
       
   489         :param replacemode: defines how the replacement should be done.
       
   490         Possible values are :
       
   491          - 'replace' to replace the node's content with the generated HTML
       
   492          - 'swap' to replace the node itself with the generated HTML
       
   493          - 'append' to append the generated HTML to the node's content
       
   494         """
       
   495         url = self.build_url('view', rql=rql, vid=vid, __notemplate=1,
       
   496                              **extraparams)
       
   497         return "javascript: loadxhtml('%s', '%s', '%s')" % (
       
   498             nodeid, html_escape(url), replacemode)
       
   499 
   481     # urls/path management ####################################################
   500     # urls/path management ####################################################
   482 
   501 
   483     def url(self, includeparams=True):
   502     def url(self, includeparams=True):
   484         """return currently accessed url"""
   503         """return currently accessed url"""
   485         return self.base_url() + self.relative_path(includeparams)
   504         return self.base_url() + self.relative_path(includeparams)