[Zope] publishing a double-underscore method?
Dylan Reinhardt
zope@dylanreinhardt.com
06 May 2003 15:36:02 -0700
Hi all,
I'm working on a product where I want to publish the results of a custom
__getattr__ method. I realize overriding __getattr__ isn't generally
recommended, but it fits my specific requirements for this product.
The problem I'm having is that even very trivial returns from
__getattr__ kick out the "empty or missing docstring" error.
A trivial example that doesn't work:
----------
security.declarePublic('__getattr__')
def __getattr__(self, name):
""" I have a docstring, not that it seems to matter """
if name == 'test':
return 'this is a test'
else:
raise AttributeError, name
----------
Here's what I actually want to do:
----------
def __getattr__(self, name):
if name in self.some_mapping.keys():
return self.some_method(name).__of__(self)
else:
raise AttributeError, name
----------
Playing with this a bit, it appears that anything I attempt to return
from __getattr__ is checked for publishability **after** the return
value has been computed. Since double-underscore methods are not
typically published, I'm not surprised that I'm having trouble.
It seems there should be some directive that explicitly permits method
publication in such cases. Is there such a thing?
Thanks in advance. I'm using Zope 2.6.1 on Gentoo, if it matters.
Dylan