def translation(self, lang):
     try:
         return db.object_session(self).query(Collectionname).\
             with_parent(self).filter(db.and_(Collectionname.ln == lang,
                 Collectionname.type == 'ln')).first().value
     except:
         return ""
 def title(self):
     try:
         return db.object_session(self).query(LnkENTRYURLTITLE).\
             filter(db.and_(
                 LnkENTRYURLTITLE.url==self.origin_url,
                 LnkENTRYURLTITLE.title<>"",
                 LnkENTRYURLTITLE.broken==0)).first().title
     except:
         return self.origin_url
 def most_specific_dad(self):
     return db.object_session(self).query(Collection).\
         join(Collection.sons).\
         filter(CollectionCollection.id_son == self.id).\
         order_by(db.asc(Collection.nbrecs)).\
         first()
 def portalboxes_ln(self):
     return db.object_session(self).query(CollectionPortalbox).\
         with_parent(self).\
         options(db.joinedload_all(CollectionPortalbox.portalbox)).\
         filter(CollectionPortalbox.ln == g.ln).\
         order_by(db.desc(CollectionPortalbox.score)).all()