"""helper functions for application hooks:organization: Logilab:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses"""__docformat__="restructuredtext en"fromlogilab.common.deprecationimportdeprecated,class_movedfromcubicwebimportRepositoryErrordefentity_oldnewvalue(entity,attr):"""returns the couple (old attr value, new attr value) NOTE: will only work in a before_update_entity hook """# get new value and remove from local dict to force a db query to# fetch old valuenewvalue=entity.pop(attr,None)oldvalue=getattr(entity,attr)ifnewvalueisnotNone:entity[attr]=newvaluereturnoldvalue,newvalue@deprecated('[3.6] entity_name is deprecated, use entity.name')defentity_name(session,eid):"""return the "name" attribute of the entity with the given eid"""returnsession.entity_from_eid(eid).name@deprecated('[3.6] rproperty is deprecated, use session.schema_rproperty')defrproperty(session,rtype,eidfrom,eidto,rprop):returnsession.rproperty(rtype,eidfrom,eidto,rprop)fromcubicweb.server.hookimportSendMailOpSendMailOp=class_moved(SendMailOp)