title: Python Twisted - How to use cache() in a non-rpy script
body: <p>I am still somewhat new to Python, and have begun learning to use the Twisted framework so that I may set up an asynchronous web server. The details about storing stateful information in the Session object is pretty straightforward, but there is something that is lacking in the documentation that is throwing me off. The first line in the script on <a href="http://twistedmatrix.com/documents/current/web/howto/web-in-60/http-auth.html" rel="nofollow noreferrer">this</a> tutorial reads:</p>
  
  <pre><code>cache()
  ...rest of the script goes here
  </code></pre>
  
  <p>This is something that only works in what is called an rpy script - more about that <a href="http://twistedmatrix.com/documents/current/web/howto/web-in-60/rpy-scripts.html" rel="nofollow noreferrer">here</a>. The problem is, I don't really want to use an rpy script, and it allegedly is not a requirement. The page I referenced describes rpy scripts as being mainly for experimenting with new ideas AND NOT MUCH ELSE.</p>
  
  <p>My issue is that when I try to run a non-rpy version of my script, I get this error:</p>
  
  <pre><code>NameError: name 'cache' is not defined
  </code></pre>
  
  <p>Some additional research has told me that cache() is a part of the globals for every rpy script, so there is no need to import. However, the documentation doesn't describe how to use cache() in a non-rpy file. So, there is my question - how can I use cache() in a non-rpy file? I am pretty sure it is just a matter of knowing which module to import, which I do not. Any help will be appreciated.</p>