parameters: (self, REQUEST)
return_statement: return namespace
docstring: For the management interface, allows to filter the messages to
          show.
docstring_summary: For the management interface, allows to filter the messages to
          show.
docstring_tokens: For the management interface allows to filter the messages to show .
function: def get_namespace(self, REQUEST):
          """For the management interface, allows to filter the messages to
          show.
          """
          # Check whether there are languages or not
          languages = self.get_languages_mapping()
          if not languages:
              return {}
  
          # Input
          batch_start = REQUEST.get('batch_start', 0)
          batch_size = REQUEST.get('batch_size', 15)
          empty = REQUEST.get('empty', 0)
          regex = REQUEST.get('regex', '')
          message = REQUEST.get('msg', None)
  
          # Build the namespace
          namespace = {}
          namespace['batch_size'] = batch_size
          namespace['empty'] = empty
          namespace['regex'] = regex
  
          # The language
          lang = REQUEST.get('lang', None) or languages[0]['code']
          namespace['language'] = lang
  
          # Filter the messages
          query = regex.strip()
          try:
              query = compile(query)
          except:
              query = compile('')
  
          messages = []
          for m, t in self._messages.items():
              if query.search(m) and (not empty or not t.get(lang, '').strip()):
                  messages.append(m)
          messages.sort(filter_sort)
          # How many messages
          n = len(messages)
          namespace['n_messages'] = n
  
          # Calculate the start
          while batch_start >= n:
              batch_start = batch_start - batch_size
          if batch_start < 0:
              batch_start = 0
          namespace['batch_start'] = batch_start
          # Select the batch to show
          batch_end = batch_start + batch_size
          messages = messages[batch_start:batch_end]
          # Batch links
          namespace['previous'] = get_url(REQUEST.URL, batch_start - batch_size,
              batch_size, regex, lang, empty)
          namespace['next'] = get_url(REQUEST.URL, batch_start + batch_size,
              batch_size, regex, lang, empty)
  
          # Get the message
          message_encoded = None
          translations = {}
          if message is None:
              if messages:
                  message = messages[0]
                  translations = self.get_translations(message)
                  message = to_unicode(message)
                  message_encoded = message_encode(message)
          else:
              message_encoded = message
              message = message_decode(message_encoded)
              translations = self.get_translations(message)
              message = to_unicode(message)
          namespace['message'] = message
          namespace['message_encoded'] = message_encoded
          namespace['translations'] = translations
          namespace['translation'] = translations.get(lang, '')
          namespace['note'] = translations.get('note', '')
  
          # Calculate the current message
          namespace['messages'] = []
          for x in messages:
              x = to_unicode(x)
              x_encoded = message_encode(x)
              url = get_url(
                  REQUEST.URL, batch_start, batch_size, regex, lang, empty,
                  msg=x_encoded)
              namespace['messages'].append({
                  'message': x,
                  'message_encoded': x_encoded,
                  'current': x == message,
                  'url': url})
  
          # The languages
          for language in languages:
              code = language['code']
              language['name'] = _(language['name'], language=code)
              language['url'] = get_url(REQUEST.URL, batch_start, batch_size,
                  regex, code, empty, msg=message_encoded)
          namespace['languages'] = languages
  
          return namespace
function_tokens: def get_namespace ( self , REQUEST ) : # Check whether there are languages or not languages = self . get_languages_mapping ( ) if not languages : return { } # Input batch_start = REQUEST . get ( 'batch_start' , 0 ) batch_size = REQUEST . get ( 'batch_size' , 15 ) empty = REQUEST . get ( 'empty' , 0 ) regex = REQUEST . get ( 'regex' , '' ) message = REQUEST . get ( 'msg' , None ) # Build the namespace namespace = { } namespace [ 'batch_size' ] = batch_size namespace [ 'empty' ] = empty namespace [ 'regex' ] = regex # The language lang = REQUEST . get ( 'lang' , None ) or languages [ 0 ] [ 'code' ] namespace [ 'language' ] = lang # Filter the messages query = regex . strip ( ) try : query = compile ( query ) except : query = compile ( '' ) messages = [ ] for m , t in self . _messages . items ( ) : if query . search ( m ) and ( not empty or not t . get ( lang , '' ) . strip ( ) ) : messages . append ( m ) messages . sort ( filter_sort ) # How many messages n = len ( messages ) namespace [ 'n_messages' ] = n # Calculate the start while batch_start >= n : batch_start = batch_start - batch_size if batch_start < 0 : batch_start = 0 namespace [ 'batch_start' ] = batch_start # Select the batch to show batch_end = batch_start + batch_size messages = messages [ batch_start : batch_end ] # Batch links namespace [ 'previous' ] = get_url ( REQUEST . URL , batch_start - batch_size , batch_size , regex , lang , empty ) namespace [ 'next' ] = get_url ( REQUEST . URL , batch_start + batch_size , batch_size , regex , lang , empty ) # Get the message message_encoded = None translations = { } if message is None : if messages : message = messages [ 0 ] translations = self . get_translations ( message ) message = to_unicode ( message ) message_encoded = message_encode ( message ) else : message_encoded = message message = message_decode ( message_encoded ) translations = self . get_translations ( message ) message = to_unicode ( message ) namespace [ 'message' ] = message namespace [ 'message_encoded' ] = message_encoded namespace [ 'translations' ] = translations namespace [ 'translation' ] = translations . get ( lang , '' ) namespace [ 'note' ] = translations . get ( 'note' , '' ) # Calculate the current message namespace [ 'messages' ] = [ ] for x in messages : x = to_unicode ( x ) x_encoded = message_encode ( x ) url = get_url ( REQUEST . URL , batch_start , batch_size , regex , lang , empty , msg = x_encoded ) namespace [ 'messages' ] . append ( { 'message' : x , 'message_encoded' : x_encoded , 'current' : x == message , 'url' : url } ) # The languages for language in languages : code = language [ 'code' ] language [ 'name' ] = _ ( language [ 'name' ] , language = code ) language [ 'url' ] = get_url ( REQUEST . URL , batch_start , batch_size , regex , code , empty , msg = message_encoded ) namespace [ 'languages' ] = languages return namespace