<s> import urllib <EOL> import tornado . web <EOL> from base import BaseHandler <EOL> from models import db <EOL> class SearchHandler ( BaseHandler ) : <EOL> def get ( self ) : <EOL> query = self . breadcrumbs [ "<STR_LIT:name>" ] <EOL> content_owner = self . models . users . get ( <EOL> username = self . breadcrumbs [ "<STR_LIT>" ] ) [ <NUM_LIT:0> ] <EOL> if not content_owner : <EOL> content_owner = self . models . users . get ( <NUM_LIT:1> ) <EOL> self . breadcrumbs [ "<STR_LIT>" ] = content_owner . username <EOL> offset = ( int ( self . breadcrumbs [ "<STR_LIT>" ] ) if <EOL> self . breadcrumbs [ "<STR_LIT>" ] else <NUM_LIT:1> ) <EOL> offset -= <NUM_LIT:1> <EOL> begin = self . constants [ '<STR_LIT>' ] * offset <EOL> if query : <EOL> if ( content_owner . adult_content <EOL> and self . get_cookie ( "<STR_LIT>" ) != "<STR_LIT:1>" and not <EOL> self . is_owner_viewing ( self . breadcrumbs [ "<STR_LIT>" ] ) ) : <EOL> self . fill_template ( "<STR_LIT>" ) <EOL> return <EOL> query = urllib . unquote_plus ( query ) <EOL> resultsQuery = db . search ( profile = self . breadcrumbs [ "<STR_LIT>" ] , <EOL> query = query , begin = begin , page_size = self . constants [ '<STR_LIT>' ] ) <EOL> results = [ self . models . content ( ** result ) for result in resultsQuery ] <EOL> else : <EOL> results = [ ] <EOL> self . display [ "<STR_LIT>" ] = offset + <NUM_LIT:1> <EOL> self . display [ "<STR_LIT>" ] = self . constants [ '<STR_LIT>' ] <EOL> self . display [ "<STR_LIT>" ] = content_owner <EOL> self . display [ "<STR_LIT>" ] = query <EOL> self . display [ "<STR_LIT>" ] = results <EOL> self . fill_template ( "<STR_LIT>" ) </s>
