title: Globals and Functions... and Kivy (Python 2.7.10) (Kivy 1.9.1)
body: <p>I'm trying to use <code>Kivy</code> to add a GUI to some script. However, the following is stalling me significantly:</p>
  
  <pre><code>class SearchScreen(Screen):
      search_input = ObjectProperty()
  
      users_dic = {}
  
      def search_user(self):
          globals()["users_dic"] = GetSessionToken.find_user(
          self.search_input.text, agent_head)
  
          print globals()['users_dic']
  
          users = [key for key in users_dic.iterkeys()]
  
          self.search_results.item_strings = users
  
          self.search_results.adapter.data[:]
          self.search_results.adapter.data.extend(users)
          self.search_results._trigger_reset_populate()
  
      class userButton(ListItemButton):
          pass
  
      def getUserSession(self, user):
          global current_user, user_header, session_token
  
          current_user = user
  
          users_dic = globals()['users_dic']
  
          print users_dic
  
          try:
              user_header, session_token = GetSessionToken.UserSession(
              users_dic[user], agent_head)
              return self.root.changeScreen("operations")
          except ValueError:
              return self.root.changeScreen("denied")
  </code></pre>
  
  <p>It produces this error:</p>
  
  <pre><code> KeyError: 'users_dic'
  </code></pre>
  
  <p>I do not understand why this is working for <code>"search_user"</code> but not for <code>"getUserSession"</code>. To confirm, "search_user" prints out the dictionary:</p>
  
  <pre><code>{u'user1': u'202703', u'user2': u'202702', u'user3': u'201105'}
  </code></pre>
  
  <p>I want to be provided with "202703" when I run "getUserSession('user1')". What am I missing about <code>Globals</code>? What are the differences between the way the functions are handling "users_dic"?</p>
  
  <p>EDIT:</p>
  
  <p><code>search_user</code> is being called in the Kivy language file as follows:</p>
  
  <pre><code>&lt;SearchScreen@Screen&gt;:
      search_input: search_box
      search_results: search_results_list
      BoxLayout:
          orientation: "vertical"
          BoxLayout
              height: root.height/10
              size_hint_y: None
              TextInput:
                  id: search_box
                  size_hint_x: 75
              Button:
                  text:"Search"
                  size_hint_x: 25
                  on_press: root.search_user()
  </code></pre>
  
  <p><code>getUserSession</code> is being called within the Kivy language file as follows:</p>
  
  <pre><code>&lt;userButton&gt;:
      on_press: main.SearchScreen().getUserSession(self.text)
  </code></pre>