<s> from django import forms <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from molly . conf import all_apps <EOL> class SearchForm ( object ) : <EOL> def __new__ ( self , * args , ** kwargs ) : <EOL> try : <EOL> return self . _search_form_class ( * args , ** kwargs ) <EOL> except AttributeError : <EOL> self . _search_form_class = self . _get_search_form_class ( ) <EOL> return self . _search_form_class ( * args , ** kwargs ) <EOL> @ classmethod <EOL> def _get_search_form_class ( self ) : <EOL> APPLICATION_CHOICES = ( <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ) + tuple ( ( app . local_name , app . title ) for app in all_apps ( ) if app . application_name ) <EOL> class SearchForm ( forms . Form ) : <EOL> query = forms . CharField ( label = _ ( '<STR_LIT>' ) ) <EOL> application = forms . ChoiceField ( <EOL> label = '<STR_LIT>' , <EOL> widget = forms . HiddenInput ( ) , <EOL> choices = APPLICATION_CHOICES , <EOL> required = False , <EOL> ) <EOL> return SearchForm </s>
