[Zope-dev] How do I call careful_getattr()?

Andrew Wilcox circle@gwi.net
Wed, 24 Nov 1999 10:05:53 -0500


My TableView class allows the user to enter the name of a method to be
called.  Right now the code to call the method looks like this:

   rowIds = getattr(folder, self.rowIdsMethodName)()

"self.rowIdsMethodName" gives me the name of the method, then I use
getattr() to find the method, and then I call it.

But, it would be better if this was security checked, so that the user
couldn't type in something like "manage_delObjects" for the method name.  :)

Is this a job for careful_getattr() ?

How do I call it?  In particular, what is the "md" argument?

I'm inside of a Product method superclassing a ZClass, so I've got a "self"
and a "REQUEST" to work with.

Thanks,

Andrew