<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -38,6 +38,7 @@ def _setup():
 
     if config.bugfixer:        
         web.webapi.internalerror = web.emailerrors(config.bugfixer, web.debugerror)
+        web.internalerror = web.webapi.internalerror
     web.config.db_parameters = config.db_parameters
     web.config.db_printing = config.db_printing
 </diff>
      <filename>infogami/__init__.py</filename>
    </modified>
    <modified>
      <diff>@@ -454,18 +454,36 @@ class Infosite(object):
         #@@ getting the objects again after the invalidating thing_cache 
         #@@ will give the latest.
         objects = [self.withKey(o.key) for o in objects]
+        
+        def invalidate_cache(cache, items, check):
+            try:
+                for q in cache.keys():
+                    for item in items:
+                        if q in cache and check(q, item):
+                            del cache[q]
+            except:
+                # something went wrong in invalidating the cache.
+                print &gt;&gt; web.debug, 'Error in invalidating cache. clearing entire cache.'
+                import traceback
+                traceback.print_exc()
 
-        for q in self.things_cache.keys():
-            for o in objects:
-                if q in self.things_cache and (q.matches(o) or o.key in self.things_cache[q]):
-                    del self.things_cache[q]
-                    
-        for q in self.versions_cache.keys():
-            for v in versions:
-                if q in self.versions_cache and q.matches(v):
-                    del self.versions_cache[q]
+                # make a local copy of the items, so that it will be displayed in the error report
+                items = cache.items()
+
+                # clear the cache completely
+                cache.clear()
+                
+                # call web.internalerror to send email when web.internalerror is set to web.emailerrors
+                web.internalerror()
+                web.ctx.output = &quot;&quot;
+                
+        invalidate_cache(self.things_cache, objects, 
+            lambda q, o: q.matches(o) and o.key in self.things_cache)
+            
+        invalidate_cache(self.versions_cache, versions, 
+            lambda q, v: q.matches(v))
         
     def get_account_manager(self):
         import account
         return account.AccountManager(self)
-        
\ No newline at end of file
+        </diff>
      <filename>infogami/infobase/infobase.py</filename>
    </modified>
    <modified>
      <diff>@@ -37,6 +37,10 @@ def jsonify(f):
             d['status'] = 'fail'
             d['message'] = 'InternalError: %s' % str(e)
             d['traceback'] = traceback.format_exc()
+            
+            # call web.internalerror to send email when web.internalerror is set to web.emailerrors
+            web.internalerror()
+            web.ctx.output = &quot;&quot;
         
         t2 = time.time()
         i = input(prettyprint=None, stats=None)</diff>
      <filename>infogami/infobase/server.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>de926162e2ae2b9cd67a75312130531a1fb0b508</id>
    </parent>
  </parents>
  <author>
    <name>anand@ia301537.us.archive.org</name>
    <email>anand@ia301537.us.archive.org</email>
  </author>
  <url>http://github.com/infogami/infogami/commit/dc4f7d3dfe83551401a9ddffd8a30fddbf5bf2e3</url>
  <id>dc4f7d3dfe83551401a9ddffd8a30fddbf5bf2e3</id>
  <committed-date>2008-07-10T18:55:48-07:00</committed-date>
  <authored-date>2008-07-10T18:55:48-07:00</authored-date>
  <message>clear cache and report error on infobase exceptions</message>
  <tree>155b701548878dd7afb9c804bbb4c6d427e118fa</tree>
  <committer>
    <name>anand@ia301537.us.archive.org</name>
    <email>anand@ia301537.us.archive.org</email>
  </committer>
</commit>
