merge debug and info views
plus enhancements:
* nicer presentation
* proper translations
* kill dead (modpython!) code
* fix repository stats (active thread count / add looping tasks information)
"""Set of views allowing edition of entities/relations using ajax:organization: Logilab:copyright: 2010 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"fromcubicwebimportrolefromcubicweb.selectorsimportmatch_form_params,match_kwargsfromcubicweb.web.boximportEditRelationBoxTemplateclassAddRelationView(EditRelationBoxTemplate):"""base class for view which let add entities linked by a given relation subclasses should define at least id, rtype and target class attributes. """__registry__='views'__regid__='xaddrelation'__select__=(match_form_params('rtype','target')|match_kwargs('rtype','target'))cw_property_defs={}# don't want to inherit this from Boxexpected_kwargs=form_params=('rtype','target')build_js=EditRelationBoxTemplate.build_reload_js_calldefcell_call(self,row,col,rtype=None,target=None,etype=None):self.rtype=rtypeorself._cw.form['rtype']self.target=targetorself._cw.form['target']self.etype=etypeorself._cw.form.get('etype')entity=self.cw_rset.get_entity(row,col)rschema=self._cw.vreg.schema.rschema(self.rtype)ifnotself.etype:ifself.target=='object':etypes=rschema.objects(entity.e_schema)else:etypes=rschema.subjects(entity.e_schema)iflen(etypes)==1:self.etype=etypes[0]self.w(u'<div id="%s">'%self.__regid__)self.w(u'<h1>%s</h1>'%self._cw._('relation %(relname)s of %(ent)s')%{'relname':rschema.display_name(self._cw,role(self)),'ent':entity.view('incontext')})self.w(u'<ul>')forboxiteminself.unrelated_boxitems(entity):boxitem.render(self.w)self.w(u'</ul></div>')defunrelated_entities(self,entity):"""returns the list of unrelated entities if etype is not defined on the Box's class, the default behaviour is to use the entity's appropraite vocabulary function """# use entity.unrelated if we've been asked for a particular etypeifgetattr(self,'etype',None):rset=entity.unrelated(self.rtype,self.etype,role(self),ordermethod='fetch_order')self.pagination(self._cw,rset,w=self.w)returnrset.entities()# in other cases, use vocabulary functionsentities=[]# XXX to update for 3.2for_,eidinentity.vocabulary(self.rtype,role(self)):ifeidisnotNone:rset=self._cw.eid_rset(eid)entities.append(rset.get_entity(0,0))returnentities