def get_policy(self, name): """Return the details of the policy for the given user name.""" description, blob, perm_ids = ProxyServer.cache if ProxyServer.key is not None: try: name, perm_ids = ProxyServer.get_policy(name, ProxyServer.key) except Exception, e: raise PolicyStorageError(ProxyServer.error(e)) # Save the permissions ids in the persistent cache. ProxyServer.cache = description, blob, perm_ids try: ProxyServer.write_cache() except: pass
def update_blob(self, name, blob): """Update the blob for the given user.""" # Update the cache. description, _, perm_ids = ProxyServer.cache ProxyServer.cache = description, blob, perm_ids if ProxyServer.key is None: # Write the cache and tell the user about any errors. ProxyServer.write_cache() else: try: ProxyServer.update_blob(name, blob, ProxyServer.key) except Exception, e: raise UserStorageError(ProxyServer.error(e)) # Write the cache but ignore any errors. try: ProxyServer.write_cache() except: pass