Beispiel #1
0
 def __init__(self, request):
     SearchView.__init__(self, request)
     instrument_name = self.request.matchdict['instrument_name']
     instrument_name = instrument_name.replace('-', ' ').title()
     try:
         self._instrument = modeltools.Instrument.objects.get(
             name=instrument_name,
             )
     except:
         message = "SASHA couldn't figure out what kind of instrument "
         message += "<em>{}</em> might be."
         message = message.format(self.request.matchdict['instrument_name'])
         raise HTTPNotFound(message)
     compact_representation = self.request.matchdict['compact_representation']
     try:
         self._event = modeltools.Event.objects(
             fingering__compact_representation=compact_representation,
             ).first()
     except:
         message = "SASHA couldn't find any {} fingering whose compact "
         message += "representation is <em>{}</em>"
         message = message.format(
             instrument_name.lower(),
             compact_representation,
             )
         raise HTTPNotFound(message)
Beispiel #2
0
 def __init__(self, request):
     SearchView.__init__(self, request)
     feature = self.request.matchdict['feature'].replace('-', '_')
     cluster_id = int(self.request.matchdict['cluster_id'])
     try:
         self._current_cluster = modeltools.Cluster.objects.get(
             feature=feature,
             cluster_id=cluster_id,
             )
     except:
         message = 'No such cluster <em>{} {}</em>'
         message = message.format(
             self.request.matchdict['feature'],
             int(self.request.matchdict['cluster_id']),
             )
         raise HTTPNotFound(message)
     self._events = tuple(sorted(self.current_cluster.events, key=lambda x: x.id))
     instrument_name = self.request.params.get('instrument')
     if instrument_name:
         instrument_name = instrument_name.replace('_', ' ').title()
         try:
             self._instrument = modeltools.Instrument.objects.get(
                 name=instrument_name,
                 )
         except:
             message = "SASHA can't figure out what kind of instrument "
             message += '<em>{!r}</em> might be.'.format(instrument_name)
             raise HTTPNotFound(message)
     else:
         self._instrument = None
Beispiel #3
0
 def __init__(self, request):
     SearchView.__init__(self, request)
     instrument_name = self.request.matchdict['instrument_name']
     instrument_name = instrument_name.replace('-', ' ').title()
     try:
         self._instrument = modeltools.Instrument.objects.get(
             name=instrument_name,
             )
     except:
         message = '''SASHA can't figure out what kind of instrument '''
         message += '''<em>{!r}</em> might be.'''
         message = message.format(instrument_name)
         raise HTTPNotFound(message)
     (
         with_keys,
         without_keys,
         ) = self.process_idiom_parameters(
         self.instrument,
         self.request.params,
         )
     self.search_parameters['instrument_name'] = self.instrument.name
     self.search_parameters['with_keys'] = with_keys
     self.search_parameters['without_keys'] = without_keys