[server] use unicode wherever appropriate in transaction/undo related methods
Silences lgdb/sqlite warnings about using str instead of unicode.
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr## This file is part of CubicWeb.## CubicWeb is free software: you can redistribute it and/or modify it under the# terms of the GNU Lesser General Public License as published by the Free# Software Foundation, either version 2.1 of the License, or (at your option)# any later version.## CubicWeb is distributed in the hope that it will be useful, but WITHOUT# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more# details.## You should have received a copy of the GNU Lesser General Public License along# with CubicWeb. If not, see <http://www.gnu.org/licenses/>."""abstract action classes for CubicWeb web clientActions are typically displayed in an action box, but can also be usedin other parts of the interface (the user menu, the footer, etc.). The'order', 'category' and 'title' class attributes control how the action willbe displayed. The 'submenu' attribute is only used for actions in theaction box.The most important method from a developper point of view in the:meth:'Action.url' method, which returns a URL on which the navigationshould be directed to perform the action. The common way ofwriting that method is to simply return a URL to the current rset with aspecial view (with `self._cw.build_url(...)` for instance) Many examples are available in :mod:`cubicweb.web.views.actions`."""__docformat__="restructuredtext en"_=unicodefromcubicwebimporttargetfromcubicweb.predicatesimport(partial_relation_possible,match_search_state,one_line_rset)fromcubicweb.appobjectimportAppObjectclassAction(AppObject):"""abstract action. Handle the .search_states attribute to match request search state. """__registry__='actions'__select__=match_search_state('normal')order=99category='moreactions'# actions in category 'moreactions' can specify a sub-menu in which they should be filedsubmenu=Nonedefactual_actions(self):yieldselfdeffill_menu(self,box,menu):"""add action(s) to the given submenu of the given box"""foractioninself.actual_actions():menu.append(box.action_link(action))defhtml_class(self):ifself._cw.selected(self.url()):return'selected'defbuild_action(self,title,url,**kwargs):returnUnregisteredAction(self._cw,title,url,**kwargs)defurl(self):"""return the url associated with this action"""raiseNotImplementedErrorclassUnregisteredAction(Action):"""non registered action, used to build boxes"""category=Noneid=Nonedef__init__(self,req,title,url,**kwargs):Action.__init__(self,req)self.title=req._(title)self._url=urlself.__dict__.update(kwargs)defurl(self):returnself._urlclassLinkToEntityAction(Action):"""base class for actions consisting to create a new object with an initial relation set to an entity. Additionaly to EntityAction behaviour, this class is parametrized using .rtype, .role and .target_etype attributes to check if the action apply and if the logged user has access to it (see :class:`~cubicweb.selectors.partial_relation_possible` selector documentation for more information). """__select__=(match_search_state('normal')&one_line_rset()&partial_relation_possible(action='add',strict=True))submenu='addrelated'# to be defined in concrete classestarget_etype=rtype=Nonedefurl(self):ttype=self.target_etypeentity=self.cw_rset.get_entity(self.cw_rowor0,self.cw_color0)linkto='%s:%s:%s'%(self.rtype,entity.eid,target(self))returnself._cw.vreg["etypes"].etype_class(ttype).cw_create_url(self._cw,__redirectpath=entity.rest_path(),__linkto=linkto,__redirectvid=self._cw.form.get('__redirectvid',''))