web/action.py
branchtls-sprint
changeset 651 ab6e15854f8c
parent 648 a89ba1054cb2
child 652 603c782dc092
equal deleted inserted replaced
650:75b4c661f71b 651:ab6e15854f8c
     8 
     8 
     9 from cubicweb import target
     9 from cubicweb import target
    10 from cubicweb.common.appobject import AppRsetObject
    10 from cubicweb.common.appobject import AppRsetObject
    11 from cubicweb.common.registerers import action_registerer
    11 from cubicweb.common.registerers import action_registerer
    12 from cubicweb.common.selectors import user_can_add_etype, \
    12 from cubicweb.common.selectors import user_can_add_etype, \
    13      match_search_state, searchstate_accept_one, \
    13      match_search_state, searchstate_accept_one
    14      searchstate_accept_one_but_etype
    14 
    15     
       
    16 _ = unicode
    15 _ = unicode
    17 
    16 
    18 
    17 
    19 class Action(AppRsetObject):
    18 class Action(AppRsetObject):
    20     """abstract action. Handle the .search_states attribute to match
    19     """abstract action. Handle the .search_states attribute to match
    62         
    61         
    63     def url(self):
    62     def url(self):
    64         return self._path
    63         return self._path
    65 
    64 
    66 
    65 
    67 class AddEntityAction(Action):
       
    68     """link to the entity creation form. Concrete class must set .etype and
       
    69     may override .vid
       
    70     """
       
    71     __selectors__ = (user_can_add_etype,)
       
    72     vid = 'creation'
       
    73     etype = None
       
    74     
       
    75     def url(self):
       
    76         return self.build_url(vid=self.vid, etype=self.etype)
       
    77 
       
    78 
       
    79 class EntityAction(Action):
    66 class EntityAction(Action):
    80     """an action for an entity. By default entity actions are only
    67     """an action for an entity. By default entity actions are only
    81     displayable on single entity result if accept match.
    68     displayable on single entity result if accept match.
    82     """
    69     """
    83     # XXX deprecate
    70     # XXX deprecate