75926e7d22316ca9465d0c095214d376f8a31fc9
3 from pylons
import request
, response
, session
, tmpl_context
as c
4 from pylons
.controllers
.util
import abort
, redirect_to
6 from floof
.lib
.base
import BaseController
, render
8 log
= logging
.getLogger(__name__
)
10 from floof
.model
.art
import Art
, Tag
, TagText
13 class SearchController(BaseController
):
16 # Return a rendered template
17 #return render('/search.mako')
18 # or, return a response
22 """ Search, implemented the stupid way! """
23 query
= request
.params
.get('query','')
26 tagtexts
= TagText
.query
.filter(TagText
.text
.in_(tags
))
27 tagtext_ids
= map(lambda x
:x
.id, tagtexts
)
29 # TODO: this is wrong. Please fix it so it returns art that has all the tags.
30 art_tag_pairs
= elixir
.session
.query(Art
,Tag
).filter(Art
.id == Tag
.art_id
).\
31 filter(Tag
.tagtext_id
.in_(tagtext_ids
)).all()
33 # just the art please.
34 c
.artwork
= map(lambda x
: x
[0], art_tag_pairs
)
35 return render('/index.mako')