[Twisted-Python] dropin.cache?

So, I've been making great strides with my plugin system, using twisted's plugin support, but there's just one small issue I'm having that I can't seem to figure out. Traceback (most recent call last): File "/Users/phil/Workspace/modu/modu/web/wsgi.py", line 16, in handler application = app.get_application(env) File "/Users/phil/Workspace/modu/modu/web/app.py", line 34, in get_application _load_plugins(env) File "/Users/phil/Workspace/modu/modu/web/app.py", line 53, in _load_plugins for site_plugin in plugin.getPlugins(ISite, modu.plugins): File "/Users/phil/Workspace/Twisted/twisted/plugin.py", line 186, in getPlugins allDropins = getCache(package) --- <exception caught here> --- File "/Users/phil/Workspace/Twisted/twisted/plugin.py", line 165, in getCache dropinPath.setContent(pickle.dumps(dropinDotCache)) File "/Users/phil/Workspace/Twisted/twisted/python/filepath.py", line 525, in setContent sib.open('w').write(content) File "/Users/phil/Workspace/Twisted/twisted/python/filepath.py", line 369, in open return open(self.path, mode+'b') exceptions.IOError: [Errno 13] Permission denied: '/Users/phil/ Workspace/modu/examples/basic/modu/plugins/dropin.cache.new' The issue is that my app doesn't have write access to the various plugin directories by default, as it runs as a restricted user. This is basically a configuration detail that my users will have to take care of, but I'd like to be able to catch this error and provide a nicer message, or at least not have my logfile filled up with stack traces. The problem is that putting a try/catch around getPlugins doesn't work, or doesn't appear to. I've looked at the code in getPlugins, and I can't figure out why the exception isn't being caught. Since I'm not actually using the reactor, I would assume there's no deferred trickery that needs to be done, so I'm at a bit of a loss. Any help in this matter would be appreciated... -phil

On Tue, 10 Jul 2007 16:00:01 -0400, Phil Christensen <phil@bubblehouse.org> wrote:
It only needs write access to update the cache, and it only needs to update the cache when a new plugin is installed on the system or an old plugin is removed. So, you should be able to completely address this by regenerating the cache at installation time (you can generate the cache simply by calling getPlugins and exhausting the iterator it returns).
There's an open ticket for changing the reporting of this condition from a full traceback to a shorter message: http://twistedmatrix.com/trac/ticket/2409 (Hmm, although that's not quite what I remembered, maybe there's another one as well). Jean-Paul

On Jul 10, 2007, at 4:48 PM, Jean-Paul Calderone wrote:
So, I now understand why I couldn't catch the error -- I just happened to be doing my own logging to stderr and thought the log messages I saw were an actual traceback. I have a simple solution for this issue, if anyone would care to check out my patch attached to the ticket above. I know this is a pretty minor issue, but it's tickling my "coder's OCD" ;-)... -phil

On Tue, 10 Jul 2007 16:00:01 -0400, Phil Christensen <phil@bubblehouse.org> wrote:
It only needs write access to update the cache, and it only needs to update the cache when a new plugin is installed on the system or an old plugin is removed. So, you should be able to completely address this by regenerating the cache at installation time (you can generate the cache simply by calling getPlugins and exhausting the iterator it returns).
There's an open ticket for changing the reporting of this condition from a full traceback to a shorter message: http://twistedmatrix.com/trac/ticket/2409 (Hmm, although that's not quite what I remembered, maybe there's another one as well). Jean-Paul

On Jul 10, 2007, at 4:48 PM, Jean-Paul Calderone wrote:
So, I now understand why I couldn't catch the error -- I just happened to be doing my own logging to stderr and thought the log messages I saw were an actual traceback. I have a simple solution for this issue, if anyone would care to check out my patch attached to the ticket above. I know this is a pretty minor issue, but it's tickling my "coder's OCD" ;-)... -phil
participants (2)
-
Jean-Paul Calderone
-
Phil Christensen