def admin_search(self, search): return self.join(MediaFullText)\ .filter(_MatchAgainstClause(_search_cols['admin'], _search_param, True))\ .order_by(MediaFullText.admin_relevance.desc())\ .params({_search_param.key: search})
return self.url elif self.embed is not None: return external_embedded_containers[self.container]['link'] % self.embed else: return helpers.url_for(controller='/media', action='serve', slug=self.media.slug, id=self.id, container=self.container, qualified=qualified) class MediaFullText(object): query = DBSession.query_property() mapper(MediaFile, media_files) mapper(MediaFullText, media_fulltext, properties={ 'relevance': column_property(_MatchAgainstClause(_search_cols['public'], _search_param, False), deferred=True), 'admin_relevance': column_property(_MatchAgainstClause(_search_cols['admin'], _search_param, False), deferred=True), }) _media_mapper = mapper(Media, media, properties={ 'fulltext': relation(MediaFullText, uselist=False, passive_deletes=True), 'author': composite(Author, media.c.author_name, media.c.author_email), 'files': relation(MediaFile, backref='media', order_by=media_files.c.type.asc(), passive_deletes=True), 'tags': relation(Tag, secondary=media_tags, backref=backref('media', lazy='dynamic', query_class=MediaQuery), collection_class=TagList, passive_deletes=True), 'categories': relation(Category, secondary=media_categories, backref=backref('media', lazy='dynamic', query_class=MediaQuery), collection_class=CategoryList, passive_deletes=True), 'comments': dynamic_loader(Comment, backref='media', query_class=CommentQuery, passive_deletes=True), 'comment_count': column_property( sql.select([sql.func.count(comments.c.id)], media.c.id == comments.c.media_id).label('comment_count'), deferred=True),