web/controller.py
branchstable
changeset 4741 f9a176ebe090
parent 4719 aaed3f813ef8
child 4878 2f75a8439338
equal deleted inserted replaced
4740:fee30ae3bc08 4741:f9a176ebe090
    59         # attributes use to control after edition redirection
    59         # attributes use to control after edition redirection
    60         self._after_deletion_path = None
    60         self._after_deletion_path = None
    61         self._edited_entity = None
    61         self._edited_entity = None
    62 
    62 
    63     def publish(self, rset=None):
    63     def publish(self, rset=None):
    64         """publish the current request, with an option input rql string
    64         """publish the current request, with an optional input rset"""
    65         (already processed if necessary)
       
    66         """
       
    67         raise NotImplementedError
    65         raise NotImplementedError
    68 
    66 
    69     # generic methods useful for concret implementations ######################
    67     # generic methods useful for concrete implementations ######################
    70 
    68 
    71     def process_rql(self, rql):
    69     def process_rql(self, rql):
    72         """execute rql if specified"""
    70         """execute rql if specified"""
    73         # XXX assigning to self really necessary?
    71         # XXX assigning to self really necessary?
    74         self.cw_rset = None
    72         self.cw_rset = None
   100         #       rest_path() could rely on schema constraints (such as a required
    98         #       rest_path() could rely on schema constraints (such as a required
   101         #       relation) that might not be satisfied yet (in case of creations)
    99         #       relation) that might not be satisfied yet (in case of creations)
   102         if not self._edited_entity:
   100         if not self._edited_entity:
   103             self._edited_entity = entity
   101             self._edited_entity = entity
   104 
   102 
       
   103     # XXX move to EditController (only customer)
   105     def delete_entities(self, eidtypes):
   104     def delete_entities(self, eidtypes):
   106         """delete entities from the repository"""
   105         """delete entities from the repository"""
   107         redirect_info = set()
   106         redirect_info = set()
   108         eidtypes = tuple(eidtypes)
   107         eidtypes = tuple(eidtypes)
   109         for eid, etype in eidtypes:
   108         for eid, etype in eidtypes:
   123 
   122 
   124     def validate_cache(self, view):
   123     def validate_cache(self, view):
   125         view.set_http_cache_headers()
   124         view.set_http_cache_headers()
   126         self._cw.validate_cache()
   125         self._cw.validate_cache()
   127 
   126 
       
   127     # XXX is that used AT ALL ?
   128     def reset(self):
   128     def reset(self):
   129         """reset form parameters and redirect to a view determinated by given
   129         """reset form parameters and redirect to a view determinated by given
   130         parameters
   130         parameters
   131         """
   131         """
   132         newparams = {}
   132         newparams = {}
   139             self._return_to_lastpage(newparams)
   139             self._return_to_lastpage(newparams)
   140         else:
   140         else:
   141             self._return_to_original_view(newparams)
   141             self._return_to_original_view(newparams)
   142 
   142 
   143 
   143 
       
   144     # XXX is that used AT ALL ?
   144     def _return_to_original_view(self, newparams):
   145     def _return_to_original_view(self, newparams):
   145         """validate-button case"""
   146         """validate-button case"""
   146         # transforms __redirect[*] parameters into regular form parameters
   147         # transforms __redirect[*] parameters into regular form parameters
   147         newparams.update(redirect_params(self._cw.form))
   148         newparams.update(redirect_params(self._cw.form))
   148         # find out if we have some explicit `rql` needs
   149         # find out if we have some explicit `rql` needs
   171             path = 'view'
   172             path = 'view'
   172         url = self._cw.build_url(path, **newparams)
   173         url = self._cw.build_url(path, **newparams)
   173         url = append_url_params(url, self._cw.form.get('__redirectparams'))
   174         url = append_url_params(url, self._cw.form.get('__redirectparams'))
   174         raise Redirect(url)
   175         raise Redirect(url)
   175 
   176 
   176 
   177     # XXX is that used AT ALL ?
   177     def _return_to_edition_view(self, newparams):
   178     def _return_to_edition_view(self, newparams):
   178         """apply-button case"""
   179         """apply-button case"""
   179         form = self._cw.form
   180         form = self._cw.form
   180         if self._edited_entity:
   181         if self._edited_entity:
   181             path = self._edited_entity.rest_path()
   182             path = self._edited_entity.rest_path()
   195             if redirectparam in form:
   196             if redirectparam in form:
   196                 newparams[redirectparam] = form[redirectparam]
   197                 newparams[redirectparam] = form[redirectparam]
   197         raise Redirect(self._cw.build_url(path, **newparams))
   198         raise Redirect(self._cw.build_url(path, **newparams))
   198 
   199 
   199 
   200 
       
   201     # XXX is that used AT ALL ?
   200     def _return_to_lastpage(self, newparams):
   202     def _return_to_lastpage(self, newparams):
   201         """cancel-button case: in this case we are always expecting to go back
   203         """cancel-button case: in this case we are always expecting to go back
   202         where we came from, and this is not easy. Currently we suppose that
   204         where we came from, and this is not easy. Currently we suppose that
   203         __redirectpath is specifying that place if found, else we look in the
   205         __redirectpath is specifying that place if found, else we look in the
   204         request breadcrumbs for the last visited page.
   206         request breadcrumbs for the last visited page.