[migration] fix 3.5.3_Any.py for migrations starting from before 3.5
"""overrides some base views for cubicweb on google appengine:organization: Logilab:copyright: 2008-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.mtconverterimportxml_escapefromcubicwebimporttyped_eidfromcubicweb.selectorsimportone_line_rset,match_search_state,acceptfromcubicweb.schemaimportdisplay_namefromcubicweb.common.viewimportStartupView,EntityViewfromcubicweb.webimportRedirectfromcubicweb.web.viewsimportvid_from_rsetfromgoogle.appengine.apiimportmailclassSearchForAssociationView(EntityView):"""view called by the edition view when the user asks to search for something to link to the edited eid """id='search-associate'__select__=one_line_rset()&match_search_state('linksearch')&acceptdefcell_call(self,row,col):entity=self.entity(0,0)role,eid,rtype,etype=self.req.search_state[1]assertentity.eid==typed_eid(eid)rset=entity.unrelated(rtype,etype,role,ordermethod='fetch_order')vid=vid_from_rset(self.req,rset,self.schema)self.w(u'<div id="search-associate-content">')self.pagination(self.req,rset,w=self.w)self.wview(vid,rset)self.w(u'</div>')classSchemaImageView(StartupView):id='schemagraph'binary=Truecontent_type='image/png'defcall(self):"""display global schema information"""skipmeta=int(self.req.form.get('skipmeta',1))ifskipmeta:url=self.build_url('data/schema.png')else:url=self.build_url('data/metaschema.png')raiseRedirect(url)fromcubicweb.web.views.baseviewsimportMetaDataViewclassGAEMetaDataView(MetaDataView):show_eid=Falsefromcubicweb.web.views.startupimportManageViewdefentity_types_no_count(self,eschemas):"""return a list of formatted links to get a list of entities of a each entity's types """req=self.reqforeschemaineschemas:ifeschema.is_final()ornot(eschema.has_perm(req,'read')oreschema.has_local_role('read')):continueetype=eschema.typelabel=display_name(req,etype,'plural')view=self.vreg.select('views','list',req,req.etype_rset(etype))url=view.url()etypelink=u' <a href="%s">%s</a>'%(xml_escape(url),label)yield(label,etypelink,self.add_entity_link(eschema,req))ManageView.entity_types=entity_types_no_countfromcubicweb.web.views.basecontrollersimportSendMailControllerdefsendmail(self,recipient,subject,body):sender='%s <%s>'%(self.req.user.dc_title()orself.config['sender-name'],self.req.user.get_email()orself.config['sender-addr'])mail.send_mail(sender=sender,to=recipient,subject=subject,body=body)SendMailController.sendmail=sendmail