[Zope] declarePublic function

Martijn Pieters mj at zopatista.com
Tue Jan 27 08:28:10 EST 2009


On Tue, Jan 27, 2009 at 14:06, Milos Prudek <prudek at bvx.cz> wrote:
> I would like to upgrade my site from Zope 2.7.x to Zope 2.10.x
>
> When I try to run my site under Zope 2.10.x, I get this exception:
>
>  class JMZPTMacros:
>  File "/home/orl/Zope/Products/JMZPTMacros/JMZPTMacros.py", line 28, in
> JMZPTMacros
>    security.declarePublic()
> TypeError: declarePublic() takes at least 2 arguments (1 given)
>
> I need to use JMZPTMacros. It is an old product that seems to require a patch
> to line 28. I can see that Zope 2.7.x defines declarePublic() as:
> def declarePublic(self, *names):
>
> and that Zope 2.10.x defines declarePublic() as:
> def declarePublic(self, name, *names):
>
> therefore I understand that one parameter is obligatory. But I cannot guess
> what parameter it should be for JMZPTMacros. I tried to look how
> declarePublic is used inside Zope but it gave me no clue.

declarePublic was never meant to be called without any names, hence
the signature change. Calling it without names is a bug in
JMZPTMacros. Most likely, the author meant to protect the method right
below that line.

To illustrate, the code probably looks something like:

  security.declarePublic()
  def someMethod(self, REQUEST):
        """Whatever"""

You put the name of that method in a string:

  security.declarePublic('someMethod')

It could also be that the author assumed that not putting in a method
name meant that *all* methods on the class would be public. In that
case, you'll need to use declareObjectPublic() instead.

-- 
Martijn Pieters


More information about the Zope mailing list