I can see 3 ways to do it, but none (None :-) is exactly what you want, except on relying on heavy machinery.
methods starting with
_
aren't published, so it might be ok for you to do it:class MyClass: def _method(self): "I have a docstring, but I won't be published" return 'done'
you can set role to
ACCESS_PRIVATE
from AccessControl.SecurityInfo import ACCESS_PRIVATE class MyClass: myMethod__roles__ = ACCESS_PRIVATE def myMethod(self): "I look like I'm published, but I'm not" return 'done'
In my opinion, the closest to what you want to achieve, but be aware that the behaviour is different from a missing docstring: if the method is called while it has no docstring, the result is a
NotFound
exception, while in theACCESS_PRIVATE
case, the result is an Unauthorized exception.You can replace the traversal method (I think) by implementing your own
IBrowserPublisher
. The default implementation isDefaultPublishTraverse
inZPublisher/BaseRequest.py
. You then have to make your own by copying it and tweak it so that it uses another flag than docstring for publication.